/// <summary> /// 执行查询的存储过程[带输入参数] /// </summary> /// <param name="storeProcName"></param> /// <param name="prams"></param> /// <returns></returns> public DataSet ExecProcQuery(string storeProcName, ParCollection prams = null) { try { base.myAdapter = new SqlDataAdapter(storeProcName, DBDalBase.myConnectionString); base.myAdapter.SelectCommand.CommandType = CommandType.StoredProcedure; if (prams != null) { foreach (SqlParameter parameter in prams) { if (parameter != null) { base.myAdapter.SelectCommand.Parameters.Add(parameter); } } } base.myDataSet = new DataSet(); base.myAdapter.Fill(base.myDataSet); } catch (Exception ex) { using (LogMethod lM = new LogMethod()) { lM.WriteLog(ex.Message, ex); } throw new Exception(ex.Message, ex); } finally { base.DataAdapterClose(); } return(base.myDataSet); }
/// <summary> /// Constructor linking to a Logger method /// </summary> /// <param name="loggingMethod"></param> public FieldInformationManager(LogMethod loggingMethod) { this.Log = loggingMethod; this.tables = new Dictionary<string, Dictionary<string, FieldInformation>>(); dbHandler = null; slxModelHandler = null; }
/// <summary> /// 执行查询的存储过程[带输入参数] /// </summary> /// <param name="storeProcName"></param> /// <param name="prams"></param> /// <returns></returns> public void ExecProcQueryNoReutrn(string storeProcName, ParCollection prams, string paramName, out string msg) { try { base.myAdapter = new SqlDataAdapter(storeProcName, DBDalBase.myConnectionString); base.myAdapter.SelectCommand.CommandType = CommandType.StoredProcedure; if (prams != null || prams.Count > 0) { foreach (SqlParameter parameter in prams) { if (parameter != null) { base.myAdapter.SelectCommand.Parameters.Add(parameter); } } } base.myAdapter.SelectCommand.Parameters.Add(new SqlParameter(paramName, SqlDbType.NVarChar, 5000, ParameterDirection.Output, true, 0, 0, string.Empty, DataRowVersion.Default, DBNull.Value)); base.myDataSet = new DataSet(); base.myAdapter.Fill(base.myDataSet); msg = (string)base.myAdapter.SelectCommand.Parameters[paramName].Value; } catch (Exception ex) { using (LogMethod lM = new LogMethod()) { lM.WriteLog(ex.Message, ex); } throw new Exception(ex.Message, ex); } finally { base.DataAdapterClose(); } }
/// <summary>This IBusinessLogicVisitor requires a reference to the ServiceInterface Visitor, /// instead of making it a public variable to all visitors, it is a required argument during construction</summary> /// <param name="serviceInterface">BusinessLogicServiceInterface</param> /// <param name="useConfigManagement">Depending if we're in </param> /// <param name="onLog">Argue a lambda which logs a debug message to your choosing</param> public BusinessLogicMultirateProcessor(BusinessLogicServiceInterface serviceInterface, bool useConfigManagement, LogMethod onLog = null) : base() { _serviceInterface = serviceInterface; _useConfigManagement = useConfigManagement; _onLog = onLog != null ? onLog : LogFallback; }
public static Assembly TryLoadAssembly([NotNull] string name, [NotNull] string codeBase, [CanBeNull] LogMethod logMethod = null) { if (_loadingAssembly) { TryLog(logMethod, "Recursive TryLoadAssembly() call ({0})", name); return(null); } try { _loadingAssembly = true; TryLog(logMethod, "Attempting to load assembly '{0}' from codebase '{1}'", name, codeBase); var assemblyName = new AssemblyName(name) { CodeBase = codeBase }; return(Assembly.Load(assemblyName)); } catch (Exception e) { TryLog(logMethod, "Error loading assembly name '{0}': {1}", name, e.Message); return(null); } finally { _loadingAssembly = false; } }
/// <summary> /// Writes the event to the Common.Logging infrastructure /// </summary> protected override void Write(LogEventInfo logEvent) { ILog logger = LogManager.GetLogger(logEvent.LoggerName); LogMethod log = logMethods[logEvent.Level]; log(logger, delegate { return(this.CompiledLayout.GetFormattedMessage(logEvent)); }, logEvent.Exception); }
/// <summary> /// Execute a sequence of dirMv operations. if any fail, it will undo all operations executed. /// </summary> /// <param name="sources"></param> /// <param name="destinations"></param> /// <param name="showUi"></param> /// <param name="errMsg"></param> /// <returns></returns> public static bool stackMv(string[] sources, string[] destinations, bool showUi, out string errMsg, out bool opWasCancelled) { LogMethod logMethod = LogMethod.NONE; return(stackMv(sources, destinations, showUi, logMethod, out errMsg, out opWasCancelled)); }
public static Err safeMove(string sourceDirName, string destDirName) { sourceDirName = CSharp.cleanPath(sourceDirName); destDirName = CSharp.cleanPath(destDirName); LogMethod logMethod = LogMethod.NONE; return(safeMove(sourceDirName, destDirName, logMethod)); }
static public void ChangeToConsole() { lock (logMethodLock) { eventLog = null; logMethod = LogMethod.Console; } }
public static void Write(LogMethod method, string bizId, string key, string logCode, string msg, string createUserId, Hashtable logExt) { try { LogDBService dbService = new LogDBService(); LogInfo logInfo = new LogInfo(); logInfo.LogId = Utils.NewGuid(); logInfo.BizId = bizId; logInfo.BizName = key; logInfo.LogCode = logCode; logInfo.LogBody = msg; logInfo.CreateUserId = createUserId; if (logExt["customer_code"] != null) { logInfo.CustomerCode = logExt["customer_code"].ToString(); } if (logExt["customer_id"] != null) { logInfo.CustomerId = logExt["customer_id"].ToString(); } if (logExt["unit_code"] != null) { logInfo.UnitCode = logExt["unit_code"].ToString(); } if (logExt["unit_id"] != null) { logInfo.UnitId = logExt["unit_id"].ToString(); } if (logExt["user_code"] != null) { logInfo.UserCode = logExt["user_code"].ToString(); } if (logExt["user_id"] != null) { logInfo.UserId = logExt["user_id"].ToString(); } if (logExt["if_code"] != null) { logInfo.IfCode = logExt["if_code"].ToString(); } if (logExt["app_code"] != null) { logInfo.AppCode = logExt["app_code"].ToString(); } logInfo.LogTypeId = method == LogMethod.Error ? dbService.GetLogTypeByCode(Config.LogErrorTypeCode).LogTypeId : dbService.GetLogTypeByCode(Config.LogTraceTypeCode).LogTypeId; dbService.InsertLog(logInfo); } catch (Exception ex) { SaveFile("WriteLogException", ex.ToString()); } }
/// <summary> /// Execute a sequence of dirMv operations. if any fail, it will undo all operations executed. /// </summary> /// <param name="sources"></param> /// <param name="destinations"></param> /// <param name="showUi"></param> /// <param name="errMsg"></param> /// <returns></returns> public static bool stackMv(string[] sources, string[] destinations, bool showUi, LogMethod logMethod, out string errMsg, out bool opWasCancelled) { string errSrc = ""; string errDst = ""; return(stackMv(sources, destinations, showUi, logMethod, out errMsg, out errSrc, out errDst, out opWasCancelled)); }
/// <summary> /// Default Constructor /// </summary> public FieldInformationManager() { this.tables = new Dictionary<string, Dictionary<string, FieldInformation>>(); dbHandler = null; slxModelHandler = null; // no logger: log to console this.Log = delegate(string Msg) { Console.WriteLine(Msg); }; }
/// <summary> /// Sends the given log event to Common.Logging /// </summary> protected override void Append(LoggingEvent loggingEvent) { ILog logger = LogManager.GetLogger(loggingEvent.LoggerName); Level logLevel = GetClosestLevel(loggingEvent.Level); LogMethod log = logMethods[logLevel]; loggingEvent.Fix = FixFlags.LocationInfo; log(logger, delegate { return(RenderLoggingEvent(loggingEvent)); }, loggingEvent.ExceptionObject); }
void LogExceptionInfo(LogMethod logMethod, ExceptionLogInfo exceptionInfo, string message) { logMethod(String.Format("{0} [ {1} ]", message, exceptionInfo.Type)); if (debugMode) { // when in debug mode, log additional exception details logMethod(exceptionInfo.Content); } }
private static void TryLog([CanBeNull] LogMethod logMethod, [NotNull] string format, params object[] args) { if (logMethod == null) { return; } logMethod(string.Format(format, args)); }
/// <summary> /// Writes the event to the Common.Logging infrastructure /// </summary> protected override void Write(LogEventInfo logEvent) { if (LogManager.Adapter is NLogLoggerFactoryAdapter) { throw new ConfigurationErrorsException("routing NLog events to Common.Logging configured with NLogLoggerFactoryAdapter results in an endless recursion"); } ILog logger = LogManager.GetLogger(logEvent.LoggerName); LogMethod log = logMethods[logEvent.Level]; log(logger, () => Layout.Render(logEvent), logEvent.Exception); }
/// <summary> /// Writes the event to the Common.Logging infrastructure /// </summary> protected override void Write(LogEventInfo logEvent) { if (LogManager.Adapter is NLogLoggerFactoryAdapter) { throw new ConfigurationErrorsException("routing NLog events to Common.Logging configured with NLogLoggerFactoryAdapter results in an endless recursion"); } ILog logger = LogManager.GetLogger(logEvent.LoggerName); LogMethod log = logMethods[logEvent.Level]; log(logger, delegate { return(this.CompiledLayout.GetFormattedMessage(logEvent)); }, logEvent.Exception); }
/// <summary> /// 检查是否存在 /// </summary> /// <param name="sql"></param> /// <param name="prams"></param> /// <returns></returns> public bool Exists(StringBuilder sql, ParCollection prams) { object objResult = ""; try { base.ConnectionOpen(); base.myCommand = new SqlCommand(sql.ToString(), base.myConnection); if (prams != null) { foreach (SqlParameter paremeter in prams) { if (paremeter != null) { base.myCommand.Parameters.Add(paremeter); } } } objResult = base.myCommand.ExecuteScalar(); } catch (Exception ex) { using (LogMethod lM = new LogMethod()) { lM.WriteLog(ex.Message, ex); } throw new Exception(ex.Message, ex); } finally { base.CommandClose(); base.ConnectionClose(); } int cmdresult; if ((Object.Equals(objResult, null)) || (Object.Equals(objResult, System.DBNull.Value))) { cmdresult = 0; } else { cmdresult = int.Parse(objResult.ToString()); } if (cmdresult == 0) { return(false); } else { return(true); } }
public void Listen() { try { if (string.IsNullOrEmpty(ChannelName)) { throw new Exception("Server.Listen 需要设置通道名称。"); } if (_instances.ContainsKey(ChannelName)) { throw new Exception("Server.Listen 无法监听相同的通道名称。(" + ChannelName + ")"); } // 设置Remoting应用程序名 if (_isFirstListen) { RemotingConfiguration.ApplicationName //= "PLDC_MntBll"; //= Process.GetCurrentProcess().ProcessName; = ChannelName; // 设置formatter BinaryServerFormatterSinkProvider formatter; formatter = new BinaryServerFormatterSinkProvider(); formatter.TypeFilterLevel = TypeFilterLevel.Full; // 设置通道名称和端口 IDictionary propertyDic = new Hashtable(); propertyDic["name"] = ChannelName; propertyDic["port"] = Port; // 注册通道 tcpChnl = new TcpChannel(propertyDic, null, formatter); ChannelServices.RegisterChannel(tcpChnl, false); // 注册类型 Type t = typeof(Server); RemotingConfiguration.RegisterWellKnownServiceType( t, "ServerActivated", WellKnownObjectMode.Singleton); _isFirstListen = false; } _instances[ChannelName] = this; } catch (Exception e) { LogMethod.WriteErrLog(e); } }
/// <summary> 移除(注销)客户端 </summary> public void RmvCLT(string id) { lock (_cltL) { if (_cltL.ContainsKey(id)) { var temp = _cltL[id]; _cltL.Remove(id); LogMethod.WriteRunLog(MSG_SIGN, DateTime.Now, "Rmv client " + temp.CltInfo + "."); } } }
public void SendStt(DateTime time, string type, string key, object o) { try { if (_vi != null) { new SendSttHandle(_vi.RcvStt).BeginInvoke(time, type, key, o, null, null); //_vi.RcvStt(time, type, key, o); } } catch (Exception e) { LogMethod.WriteErrLog("IClientView", DateTime.Now, e); } }
public static ILogger GetLogger(IServiceContext context, LogMethod logMethod) { var loggerAttribute = typeof(LoggerFactory).Assembly.GetCustomAttribute <LoggerClassAttribute>(); var loggerType = typeof(DefaultLogHelper); if (loggerAttribute != null) { loggerType = loggerAttribute.LoggerClassType; } var logger = (ILogger)Activator.CreateInstance(loggerType, new object[] { context.AdminOrganizationService, context, logMethod }); return(logger); }
public IActionResult StuLog(Student student) { LogMethod log = new LogMethod(); Student m = log.StuLogin(student); if (m != null) { this.Response.Cookies.Append("Sno", m.Sno); return(RedirectToAction("Index", "Student")); } else { return(Content("<script>alert('登录失败,请检查账号或密码是否输入错误');history.go(-1);</script>", "text/html;charset=UTF-8")); } }
public IActionResult TeaLog(Teacher teacher) { LogMethod log = new LogMethod(); Teacher m = log.TeaLogin(teacher); if (m != null) { this.Response.Cookies.Append("Tno", m.Tno); return(RedirectToAction("Index", "Teacher")); } else { return(Content("<script>alert('登录失败,请检查账号或密码是否输入错误');history.go(-1);</script>", "text/html;charset=UTF-8")); } }
public IActionResult AdmLog(Administrator administrator) { LogMethod log = new LogMethod(); Administrator m = log.AdmLogin(administrator); if (m != null) { this.Response.Cookies.Append("Ano", m.Ano); return(RedirectToAction("Index", "Administrator")); } else { return(Content("<script>alert('登录失败,请检查账号或密码是否输入错误');history.go(-1);</script>", "text/html;charset=UTF-8")); } }
public AbstractLogger() { var logMethod = ConfigurationManager.AppSettings["LogMethod"].ToString(); LogMethod lm; if (Enum.TryParse <LogMethod>(logMethod, out lm)) { this.Method = lm; } else { this.Method = LogMethod.None; } }
private void Core_Login_Passed() { try { VSC = new VersionControl(); VSC.InitVersCheck(); SND = new Sounds(); SND.SoundsInit(); SCT = new SettingsControl(); SCT.SettingsInit(); VCT = new ViewControl(); VCT.ViewInit(); SCN = new Scanner(); SCN.ScannerInit(); MCL = new MacroLogic(); MCL.MacroInit(); LGM = new LogMethod(); LGM.LogInit(); DTH = new DeathParse(); DTH.ParseInit(); HUD = new HUDControl(); HUD.HUDInit(); if (lib.Autorelog == true) { if (RlgTmr.Enabled == true) { RlgTmr.Stop(); lib.Autorelog = false; MainView.Mode.Current = 0; lib.Mode = 0; Utility.AddWindowText(lib.MyServer + " : " + lib.MyName + " : " + lib.authtype + " : Current mode: SLAVE - Forced Login detected at " + DateTime.Now.ToString("h: mm:ss tt")); Utility.AddChatText("FORCED LOGIN DETECTED! Mode switched: SLAVE.", 6); } else if (RlgTmr.Enabled == false) { MainView.Mode.Current = 3; lib.Mode = 3; Utility.AddWindowText(lib.MyServer + " : " + lib.MyName + " : " + lib.authtype + " : Current mode: MACRO - Relogger is set to " + lib.Timer + " seconds."); if (lib.UseMacroLogic == true) { Utility.ActivateWindow(); } } } else if (lib.Autorelog == false) { MainView.Mode.Current = 0; lib.Mode = 0; Utility.AddWindowText(lib.MyServer + " : " + lib.MyName + " : " + lib.authtype + " : Current mode: SLAVE"); } REP = new Report(); REP.ReportInit(); Report.InitialLog("Login"); } catch (Exception ex) { Repo.RecordException(ex); } }
/// <summary> /// Logs a byte array /// </summary> /// <param name="logMethod">The method that is used for logging.</param> /// <param name="msg">A message that is displayed before the data.</param> /// <param name="buffer">The byte array that is logged</param> /// <param name="offset">The index of the first byte that is logged.</param> /// <param name="count">The number of bytes that are logged.</param> /// <param name="lineLength">Number of bytes that are displayedPerLine</param> /// <param name="blockLength">Defines how many bytes are in a block. A space is inserted after each block /// </param> private static void LogBuffer( LogMethod logMethod, string msg, byte[] buffer, long offset, long count, int lineLength, int blockLength) { // Create the string builder and add the message System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder(); stringBuilder.Append(msg); // For all bytes to be logged int linePos = 0; for (int i = 0; i < count; i++, linePos++) { // Check if a new line needs to be added. if (i % lineLength == 0) { if (i != 0) { stringBuilder.Append("\r\n"); linePos = 0; } } else { // Check if a block separation character needs to be added if (linePos % blockLength == 0) { stringBuilder.Append(" "); } } // Add the character to the string builder stringBuilder.Append(string.Format(CultureInfo.InvariantCulture, "[{0:X2}]", buffer[offset + i])); } // Use the logMethod to log the complete message. logMethod(stringBuilder.ToString()); }
/// <summary> /// 执行多条SQL语句,实现数据库事务。 /// </summary> /// <param name="SQLStringList">SQL语句的哈希表(key为sql语句,value是该语句的SqlParameter[])</param> /// <returns>事务是否成功</returns> public bool ExecSqlTran(TranCollection ltTran) { bool flag = true; base.ConnectionOpen(); base.myCommand = new SqlCommand(); myCommand.Connection = base.myConnection; string CurrentSql = ""; var curList = ltTran.OrderBy(ss => ss.Order).ToList(); using (SqlTransaction trans = base.myConnection.BeginTransaction()) { try { //循环 foreach (var tran in curList) { CurrentSql = tran.Sql.ToString(); SqlParameter[] cmdParms = tran.Pars != null?tran.Pars.ToArray() : null; PrepareCommand(base.myCommand, base.myConnection, trans, CurrentSql, cmdParms); int val = myCommand.ExecuteNonQuery(); myCommand.Parameters.Clear(); } trans.Commit(); return(flag); } catch (Exception ex) { trans.Rollback(); using (LogMethod lM = new LogMethod()) { lM.WriteLog(ex.Message + "SQL:" + CurrentSql, ex); } throw ex; } finally { base.CommandClose(); base.ConnectionClose(); } } }
static public void ChangeToEventLog(string newSource, string newEventLog) { if (string.IsNullOrEmpty(newSource) || string.IsNullOrEmpty(newEventLog)) { throw new ApplicationException("Wrong event entries"); } lock (logMethodLock) { if (!System.Diagnostics.EventLog.SourceExists(newSource)) { System.Diagnostics.EventLog.CreateEventSource( newSource, newEventLog); } eventLog = new EventLog(); eventLog.Source = newSource; eventLog.Log = newEventLog; logMethod = LogMethod.EventLog; } }
private void ToClient(LogMessage logMessage, string formattedLogMessage) { //' Dont wait for it //' If you raise asynchronously, multiple listeners would be processing your event at the same time. //' At the very least, that requires a thread-safe EventArg class. //ThreadPool.QueueUserWorkItem( // Sub() lock (_ThreadSafeClient) { // Thread safe property usage // Run client programmer's method asynchronously //LogMethod?.BeginInvoke(logMessage, formattedLogMessage, Nothing, Nothing) LogMethod?.Invoke(logMessage, formattedLogMessage); // Event OnNewLogMessage(this, new LoggerEventArgs(logMessage, formattedLogMessage)); } // End Sub) }
/// <summary> /// 执行查询的存储过程[带输入参数],[输出参数自定义] /// </summary> /// <param name="storeProcName">存储过程名称</param> /// <param name="prams">参数集合</param> /// <param name="outPubParamName">输出参数名称,必须带@</param> /// <param name="OutPutValue">输出参数</param> /// <returns></returns> public DataSet ExecProcQuery(string storeProcName, ParCollection prams, string outPubParamName, out string OutPutValue) { try { base.myAdapter = new SqlDataAdapter(storeProcName, DBDalBase.myConnectionString); base.myAdapter.SelectCommand.CommandType = CommandType.StoredProcedure; if (prams != null) { foreach (SqlParameter parameter in prams) { if (parameter != null) { base.myAdapter.SelectCommand.Parameters.Add(parameter); } } } base.myAdapter.SelectCommand.Parameters.Add(new SqlParameter(outPubParamName, SqlDbType.NVarChar, 500, ParameterDirection.Output, true, 0, 0, string.Empty, DataRowVersion.Default, DBNull.Value)); base.myDataSet = new DataSet(); base.myAdapter.Fill(base.myDataSet); object objParamVal = base.myAdapter.SelectCommand.Parameters[outPubParamName].Value; OutPutValue = string.Empty; if (objParamVal != DBNull.Value) { OutPutValue = objParamVal.ToString(); } } catch (Exception ex) { using (LogMethod lM = new LogMethod()) { lM.WriteLog(ex.Message, ex); } throw new Exception(ex.Message, ex); } finally { base.DataAdapterClose(); } return(base.myDataSet); }
static void Main(string[] args) { // ctrl+R ctr+M (Refactor Extract Method) //DateOperations(); //StaticInstanceMethods(); //ParametersDemo(); //RefOutParams(); //Action<string> log2 = LogToFile; //Func LogMethod log = LogToFile; log += LogToConsole; log += delegate(string m) { Console.WriteLine("{0}:{1}", DateTime.Now, m); }; log += (m) => { Console.WriteLine("{0}:{1}", DateTime.Now, m); }; log("message"); log("message"); log("message"); log("message"); int count = 25; int sum = 428; //Full method double average = Avg(count, sum); //Anonymous method -- delegate (params) {body} Func <int, int, double> avg = delegate(int c, int s) { return((double)s / c); }; //Lambda expression -- (params) => expression/body Func <int, int, double> avg2 = (c, s) => (double)s / c; //Func<int, int, double> -- built-in //delegate double AvgDelegate(int count, int sum); user defined average = avg2(count, sum); }
protected override MethodDefinition ImplementLogMethod(LogMethod metadata) { var method = metadata.Method; if (metadata.IsTemplate) { method.Attributes = MethodAttributes.Public | MethodAttributes.HideBySig; SetLogMethodBody(method, metadata); } UpdateEventAttribute(method, metadata); return method; }
static FunctionMethodCreator() { methodList = new Dictionary<string, FunctionMethod>(); //キャラクタデータ系 methodList["GETCHARA"] = new GetcharaMethod(); methodList["GETSPCHARA"] = new GetspcharaMethod(); methodList["CSVNAME"] = new CsvStrDataMethod(CharacterStrData.NAME); methodList["CSVCALLNAME"] = new CsvStrDataMethod(CharacterStrData.CALLNAME); methodList["CSVNICKNAME"] = new CsvStrDataMethod(CharacterStrData.NICKNAME); methodList["CSVMASTERNAME"] = new CsvStrDataMethod(CharacterStrData.MASTERNAME); methodList["CSVCSTR"] = new CsvcstrMethod(); methodList["CSVBASE"] = new CsvDataMethod(CharacterIntData.BASE); methodList["CSVABL"] = new CsvDataMethod(CharacterIntData.ABL); methodList["CSVMARK"] = new CsvDataMethod(CharacterIntData.MARK); methodList["CSVEXP"] = new CsvDataMethod(CharacterIntData.EXP); methodList["CSVRELATION"] = new CsvDataMethod(CharacterIntData.RELATION); methodList["CSVTALENT"] = new CsvDataMethod(CharacterIntData.TALENT); methodList["CSVCFLAG"] = new CsvDataMethod(CharacterIntData.CFLAG); methodList["CSVEQUIP"] = new CsvDataMethod(CharacterIntData.EQUIP); methodList["CSVJUEL"] = new CsvDataMethod(CharacterIntData.JUEL); methodList["FINDCHARA"] = new FindcharaMethod(false); methodList["FINDLASTCHARA"] = new FindcharaMethod(true); methodList["EXISTCSV"] = new ExistCsvMethod(); //汎用処理系 methodList["VARSIZE"] = new VarsizeMethod(); methodList["CHKFONT"] = new CheckfontMethod(); methodList["CHKDATA"] = new CheckdataMethod("CHKDATA", EraSaveFileType.Normal); methodList["ISSKIP"] = new IsSkipMethod(); methodList["MOUSESKIP"] = new MouseSkipMethod(); methodList["GETCOLOR"] = new GetColorMethod(false); methodList["GETDEFCOLOR"] = new GetColorMethod(true); methodList["GETFOCUSCOLOR"] = new GetFocusColorMethod(); methodList["GETBGCOLOR"] = new GetBGColorMethod(false); methodList["GETDEFBGCOLOR"] = new GetBGColorMethod(true); methodList["GETSTYLE"] = new GetStyleMethod(); methodList["GETFONT"] = new GetFontMethod(); methodList["BARSTR"] = new BarStringMethod(); methodList["CURRENTALIGN"] = new CurrentAlignMethod(); methodList["CURRENTREDRAW"] = new CurrentRedrawMethod(); methodList["CHKVARDATA"] = new CheckdataMethod("CHKVARDATA", EraSaveFileType.Var); methodList["CHKCHARADATA"] = new CheckdataMethod("CHKCHARADATA", EraSaveFileType.CharVar); //methodList["CHKGLOBALDATA"] = new CheckdataMethod("CHKGLOBALDATA", EraSaveFileType.Global); //定数取得 methodList["MONEYSTR"] = new MoneyStrMethod(); methodList["PRINTCPERLINE"] = new GetPrintCPerLineMethod(); methodList["SAVENOS"] = new GetSaveNosMethod(); methodList["GETTIME"] = new GettimeMethod(); methodList["GETTIMES"] = new GettimesMethod(); methodList["GETMILLISECOND"] = new GetmsMethod(); methodList["GETSECOND"] = new GetSecondMethod(); //数学関数 methodList["RAND"] = new RandMethod(); methodList["MIN"] = new MaxMethod(false); methodList["MAX"] = new MaxMethod(true); methodList["ABS"] = new AbsMethod(); methodList["POWER"] = new PowerMethod(); methodList["SQRT"] = new SqrtMethod(); methodList["CBRT"] = new CbrtMethod(); methodList["LOG"] = new LogMethod(); methodList["LOG10"] = new LogMethod(10.0d); methodList["EXPONENT"] = new ExpMethod(); methodList["SIGN"] = new SignMethod(); methodList["LIMIT"] = new GetLimitMethod(); //変数操作系 methodList["SUMARRAY"] = new SumArrayMethod(); methodList["SUMCARRAY"] = new SumArrayMethod(true); methodList["MATCH"] = new MatchMethod(); methodList["CMATCH"] = new MatchMethod(true); methodList["GROUPMATCH"] = new GroupMatchMethod(); methodList["NOSAMES"] = new NosamesMethod(); methodList["ALLSAMES"] = new AllsamesMethod(); methodList["MAXARRAY"] = new MaxArrayMethod(); methodList["MAXCARRAY"] = new MaxArrayMethod(true); methodList["MINARRAY"] = new MaxArrayMethod(false, false); methodList["MINCARRAY"] = new MaxArrayMethod(true, false); methodList["GETBIT"] = new GetbitMethod(); methodList["GETNUM"] = new GetnumMethod(); methodList["GETPALAMLV"] = new GetPalamLVMethod(); methodList["GETEXPLV"] = new GetExpLVMethod(); methodList["FINDELEMENT"] = new FindElementMethod(false); methodList["FINDLASTELEMENT"] = new FindElementMethod(true); methodList["INRANGE"] = new InRangeMethod(); methodList["INRANGEARRAY"] = new InRangeArrayMethod(); methodList["INRANGECARRAY"] = new InRangeArrayMethod(true); //文字列操作系 methodList["STRLENS"] = new StrlenMethod(); methodList["STRLENSU"] = new StrlenuMethod(); methodList["SUBSTRING"] = new SubstringMethod(); methodList["SUBSTRINGU"] = new SubstringuMethod(); methodList["STRFIND"] = new StrfindMethod(false); methodList["STRFINDU"] = new StrfindMethod(true); methodList["STRCOUNT"] = new StrCountMethod(); methodList["TOSTR"] = new ToStrMethod(); methodList["TOINT"] = new ToIntMethod(); methodList["TOUPPER"] = new StrChangeStyleMethod(StrFormType.Upper); methodList["TOLOWER"] = new StrChangeStyleMethod(StrFormType.Lower); methodList["TOHALF"] = new StrChangeStyleMethod(StrFormType.Half); methodList["TOFULL"] = new StrChangeStyleMethod(StrFormType.Full); methodList["LINEISEMPTY"] = new LineIsEmptyMethod(); methodList["REPLACE"] = new ReplaceMethod(); methodList["UNICODE"] = new UnicodeMethod(); methodList["UNICODEBYTE"] = new UnicodeByteMethod(); methodList["CONVERT"] = new ConvertIntMethod(); methodList["ISNUMERIC"] = new IsNumericMethod(); methodList["ESCAPE"] = new EscapeMethod(); methodList["ENCODETOUNI"] = new EncodeToUniMethod(); methodList["CHARATU"] = new CharAtMethod(); methodList["GETLINESTR"] = new GetLineStrMethod(); }
static Logger() { _logMethod = LogMethod.Console; _logLevel = LogLevel.Info; LogFile = ""; }
protected CriticalEvent(string source, string format, EventCode eventCode) : this(source,format, eventCode, LogError) { logMethod = LogError; }
protected override MethodDefinition ImplementLogMethod(LogMethod metadata) { var oldMethod = metadata.Method; // duplicate the interface method var newMethod = new MethodDefinition(oldMethod.Name, MethodAttributes.Public, module.ImportReference(oldMethod.ReturnType)); target.Methods.Add(newMethod); // implement all source parameters foreach (var p in oldMethod.Parameters) newMethod.Parameters.Add(new ParameterDefinition(p.Name, p.Attributes, module.ImportReference(p.ParameterType))); SetLogMethodBody(newMethod, metadata); UpdateEventAttribute(newMethod, metadata); return newMethod; }
private async Task<bool> Upload(RequestHeader header, ICollection<ClientFile> files, LogMethod method) { var package = await _packageHelper.PackAsync(files); var context = method.ToString(); this.LogRequest(context); await this.TransferHandler.WriteAsync(this.Id, (byte)method); var data = Utilities.Concat(header.NetworkBuffer, package); this.LogRequest(data, context); await this.TransferHandler.WriteAsync(data); var bytes = await this.TransferHandler.ReadAsync(); this.LogResponse(bytes, context); return Convert.ToBoolean(BitConverter.ToInt32(bytes, 0)); }
protected CriticalEvent(string source, string format, EventCode eventCode, LogMethod logMethod) : base(source, eventCode, TraceEventType.Critical, format) { this.logMethod = logMethod; }
private static string LogInternal( object message, LogMethod method, string source = null, string memberName = null, string sourceFilePath = null, int sourceLineNumber = 0) { Inc(); if (Config.IncludeEventId && message is Exception) { ((Exception) message).Data["_id"] = ThreadContext.Properties["id"]; }; ILog log; if (source != null) memberName = ""; if (memberName != "") memberName = string.Concat(".", memberName); ThreadContext.Properties["memberName"] = memberName; if (sourceLineNumber == 0) ThreadContext.Properties["source"] = sourceFilePath; else ThreadContext.Properties["source"] = string.Concat(sourceFilePath, ":line ", sourceLineNumber); ThreadContext.Properties["culture"] = Thread.CurrentThread.CurrentCulture.ToString(); ThreadContext.Properties["uiculture"] = Thread.CurrentThread.CurrentUICulture.ToString(); ThreadContext.Properties["request"] = FormatHttpRequest(); ThreadContext.Properties["instance"] = App.Config.InstanceId; var exception = message as Exception; if (exception != null) { Exception e = exception; log = LogManager.GetLogger(source ?? e.Source); var msg = e.Message; if (e.Data["SQL"] != null) { msg = string.Concat(msg, "\r\n", "SQL: ", e.Data["SQL"]); } switch (method) { case LogMethod.Error: log.Error(msg, e); break; case LogMethod.Warning: log.Warn(msg, e); break; case LogMethod.Info: log.Info(msg, e); break; case LogMethod.Debug: log.Debug(msg, e); break; } } else { log = LogManager.GetLogger(RetreiveSource(source)); switch (method) { case LogMethod.Error: log.Error(message); break; case LogMethod.Warning: log.Warn(message); break; case LogMethod.Info: log.Info(message); break; case LogMethod.Debug: log.Debug(message); break; } } return ThreadContext.Properties["id"].ToString(); }