本文整理汇总了C#中System.Diagnostics.StackFrame.GetMethod方法的典型用法代码示例。如果您正苦于以下问题:C# System.Diagnostics.StackFrame.GetMethod方法的具体用法?C# System.Diagnostics.StackFrame.GetMethod怎么用?C# System.Diagnostics.StackFrame.GetMethod使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Diagnostics.StackFrame
的用法示例。
在下文中一共展示了System.Diagnostics.StackFrame.GetMethod方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestContext
public void TestContext ()
{
var queue = new Loggers.Queue();
var log = new Log(this);
using (Log.RegisterInstance(
new Instance()
{
Properties = new[]
{
"StackFrame.File",
"StackFrame.Line",
"StackFrame.Type",
"StackFrame.Method"
},
Logger = queue,
Buffer = 0,
Synchronous = true
}
)
)
{
var frame = new System.Diagnostics.StackFrame(0, true);
log.Info("test");
var evt = queue.Dequeue().Single();
Assert.AreEqual(evt["StackFrame.File"], frame.GetFileName());
Assert.AreEqual(evt["StackFrame.Line"], frame.GetFileLineNumber() + 1);
Assert.AreEqual(evt["StackFrame.Type"], frame.GetMethod().DeclaringType.FullName);
Assert.AreEqual(evt["StackFrame.Method"], frame.GetMethod().Name);
}
}
示例2: dbgLog
/// <summary>
/// Our LogWrapper...used to log things so that they have our prefix prepended and logged either to custom file or not.
/// </summary>
/// <param name="sText">Text to log</param>
/// <param name="ex">An Exception - if not null it's basic data will be printed.</param>
/// <param name="bDumpStack">If an Exception was passed do you want the full stack trace?</param>
/// <param name="bNoIncMethod">If for some reason you don't want the method name prefaced with the log line.</param>
public static void dbgLog(string sText, Exception ex = null, bool bDumpStack = false, bool bNoIncMethod = false)
{
try
{
logSB.Length = 0; //clear the existing log data.
//now go get our prefix if needed and add it to the stringbuilder.
string sPrefix = string.Concat("[", SomeModName.MY_MODS_LOG_PREFIX);
if (bNoIncMethod) { string.Concat(sPrefix, "] "); }
else
{
// Here we step back a 1 frame in the stack(current frame would be logger), and add that method name
// to our prefix so you know wtf method triggered your error. ie "[ModPrefixname:SomeModClassName.TheMethodThatCausedError]:"
// Saves you from having to add that to your debug messages manually and is very handy i find.
System.Diagnostics.StackFrame oStack = new System.Diagnostics.StackFrame(1); //pop back one frame, ie our caller.
sPrefix = string.Concat(sPrefix, ":", oStack.GetMethod().DeclaringType.Name, ".", oStack.GetMethod().Name, "] ");
}
logSB.Append(string.Concat(sPrefix, sText));
//Were we sent and exception object? If so let's log it's top level error message.
if (ex != null)
{
logSB.Append(string.Concat("\r\nException: ", ex.Message.ToString()));
}
//Were we asked to log the stacktrace with that exception?
if (bDumpStack & ex !=null)
{
logSB.Append(string.Concat("\r\nStackTrace: ", ex.ToString())); //ex.tostring will return more data then ex.stracktrace.tostring
}
//If we have configuration data does it tell use to use a custom log file?
//if it does let's go use the specified full path to the custom log or use the default file name in the root of CSL folder.
if (SomeModName.config != null && SomeModName.config.UseCustomLogFile == true)
{
string strPath = System.IO.Directory.Exists(Path.GetDirectoryName(SomeModName.config.CustomLogFilePath)) ? SomeModName.config.CustomLogFilePath.ToString() : Path.Combine(DataLocation.executableDirectory.ToString(), SomeModName.config.CustomLogFilePath);
using (StreamWriter streamWriter = new StreamWriter(strPath, true))
{
streamWriter.WriteLine(logSB.ToString());
}
}
else
{
Debug.Log(logSB.ToString());
}
}
catch (Exception Exp)
{
// Well shit! even our logger errored, lets try to log in CSL log about it.
Debug.Log(string.Concat(SomeMod.SomeModName.MY_MODS_LOG_PREFIX + " Error in log attempt! ", Exp.Message.ToString()));
}
logSB.Length = 0;
if (logSB.Capacity > 16384) { logSB.Capacity = 2048;} //shrink outselves if we've grown way to large.
}
示例3: GetAuditorDetailsByWOID
/// <summary>
/// Description : Get Auditors Details from database.
/// Created By : Pavan
/// Created Date : 23 August 2014
/// Modified By :
/// Modified Date:
/// </summary>
/// <returns></returns>
public static List<Auditors> GetAuditorDetailsByWOID(int WOID)
{
var data = new List<Auditors>();
System.Diagnostics.StackFrame stackFrame = new System.Diagnostics.StackFrame();
System.Reflection.MethodBase methodBase = stackFrame.GetMethod();
log.Debug("Start: " + methodBase.Name);
try
{
SqlParameter[] sqlParams = new SqlParameter[1];
sqlParams[0] = new SqlParameter("@WOID", WOID);
var reader = SqlHelper.ExecuteReader(ConnectionUtility.GetConnectionString(), CommandType.StoredProcedure, "[SpGetAuditorDetailsByWOID]", sqlParams);
var safe = new SafeDataReader(reader);
while (reader.Read())
{
var Auditors = new Auditors();
Auditors.FetchAuditors(Auditors, safe);
data.Add(Auditors);
}
return data;
}
catch (Exception ex)
{
log.Error("Error: " + ex);
return data;
}
finally
{
log.Debug("End: " + methodBase.Name);
}
}
示例4: GetWOAddressDetails
/// <summary>
/// Description : Get WOAddress Details from database.
/// Created By : Pavan
/// Created Date : 12 August 2014
/// Modified By :
/// Modified Date:
/// </summary>
/// <returns></returns>
public static List<WOAddress> GetWOAddressDetails(int PersonID, string PersonSource)
{
var data = new List<WOAddress>();
System.Diagnostics.StackFrame stackFrame = new System.Diagnostics.StackFrame();
System.Reflection.MethodBase methodBase = stackFrame.GetMethod();
log.Debug("Start: " + methodBase.Name);
try
{
SqlParameter[] sqlParams = new SqlParameter[2];
sqlParams[0] = new SqlParameter("@PersonID", PersonID);
sqlParams[1] = new SqlParameter("@PersonSource", PersonSource);
var reader = SqlHelper.ExecuteReader(ConnectionUtility.GetConnectionString(), CommandType.StoredProcedure, "[SpGetWOAddressDetails]", sqlParams);
var safe = new SafeDataReader(reader);
while (reader.Read())
{
var woaddress = new WOAddress();
woaddress.FetchwoaddressDetails(woaddress, safe);
data.Add(woaddress);
}
return data;
}
catch (Exception ex)
{
log.Error("Error: " + ex);
return data;
}
finally
{
log.Debug("End: " + methodBase.Name);
}
}
示例5: DeleteNote
public JsonResult DeleteNote(int ID)
{
System.Diagnostics.StackFrame stackFrame = new System.Diagnostics.StackFrame();
System.Reflection.MethodBase methodBase = stackFrame.GetMethod();
log.Debug("Start: " + methodBase.Name);
try
{
int checkSession = UserLogin.AuthenticateRequest();
if (checkSession == 0)
{
return Json(checkSession);
}
else
{
var data = new Note
{
ID = ID,
CreatedBy = checkSession
};
int output = data.DeleteNote();
return Json(output);
}
}
catch (Exception ex)
{
log.Error("Error: " + ex);
return Json("");
}
finally
{
log.Debug("End: " + methodBase.Name);
}
}
示例6: GetBillingPartyInformation
/// <summary>
/// Description : Get the Client information from CSS1
/// Created By : Sudheer
/// Created Date : 14th Oct 2014
/// Modified By :
/// Modified Date:
/// </summary>
public static _ChoosenBillingPartyInfo GetBillingPartyInformation(string ClientName, string WOID)
{
var GetClientInfo = new _ChoosenBillingPartyInfo();
System.Diagnostics.StackFrame stackFrame = new System.Diagnostics.StackFrame();
System.Reflection.MethodBase methodBase = stackFrame.GetMethod();
log.Debug("Start: " + methodBase.Name);
try
{
SqlParameter[] sqlParams = new SqlParameter[2];
sqlParams[0] = new SqlParameter("@WOID", WOID);
sqlParams[1] = new SqlParameter("@ClientName", ClientName);
var reader = SqlHelper.ExecuteReader(ConnectionUtility.GetConnectionString(), CommandType.StoredProcedure, "GetAllBillingPartyDetails", sqlParams);
var safe = new SafeDataReader(reader);
while (reader.Read())
{
var ClientInfo = new _ChoosenClient();
ClientInfo.FetchBillingPartyInfo(ClientInfo, safe);
GetClientInfo._ChoosenBillingPartyList.Add(ClientInfo);
}
return GetClientInfo;
}
catch (Exception ex)
{
log.Error("Error: " + ex);
return GetClientInfo;
}
finally
{
log.Debug("End: " + methodBase.Name);
}
}
示例7: FillByUserName
internal static void FillByUserName(User user)
{
// #1- Logger variables
System.Diagnostics.StackFrame stackFrame = new System.Diagnostics.StackFrame();
string className = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name;
string methodName = stackFrame.GetMethod().Name;
string query = "SELECT id, groupName,password,passwordDate,deleted,disabled,dateCreated,dateDeleted,dateDisabled FROM incuser WHERE userName = @userName";
Hashtable param = new Hashtable();
param.Add("@userName", user.userName);
// #2- Logger pre query
Logger.LogDebug("(%s) (%s) -- Ejecuta query para obtener todos los folios. QUERY: %s", className, methodName, query);
using (DataTable dt = ExecuteDataTableQuery(query, param))
{
if (dt != null && dt.Rows.Count > 0)
{
// #3- Logger post query
Logger.LogDebug("Row count: %s", dt.Rows.Count.ToString());
DataRow row = dt.Rows[0];
user.userName = user.userName;
user.id = (row["id"] != DBNull.Value) ? row["id"].ToString() : string.Empty;
user.groupName = (row["groupName"] != DBNull.Value) ? row["groupName"].ToString() : string.Empty;
user.password = (row["password"] != DBNull.Value) ? row["password"].ToString() : string.Empty;
user.passwordDate = (row["passwordDate"] != DBNull.Value) ? DateTime.Parse(row["passwordDate"].ToString()) : DateTime.Now;
user.deleted = (row["deleted"] != DBNull.Value) ? int.Parse(row["deleted"].ToString()) : 0;
user.disabled = (row["disabled"] != DBNull.Value) ? int.Parse(row["disabled"].ToString()) : 0;
user.dateCreated = (row["dateCreated"] != DBNull.Value) ? DateTime.Parse(row["dateCreated"].ToString()) : DateTime.Now;
user.dateDeleted = (row["dateDeleted"] != DBNull.Value) ? DateTime.Parse(row["dateDeleted"].ToString()) : DateTime.Now;
user.dateDisabled = (row["dateDisabled"] != DBNull.Value) ? DateTime.Parse(row["dateDisabled"].ToString()) : DateTime.Now;
}
}
}
示例8: AuthenticateRequest
/// <summary>
/// Created By : hussain
/// Created Date : 15 May 2014
/// Modified By : Shiva
/// Modified Date : 16 Sep 2014
/// AuthenticateRequest
/// </summary>
/// <param name="Token">SessionToken</param>
/// <returns>Active Session:0 InActive Session: UserID</returns>
public static int AuthenticateRequest()
{
System.Diagnostics.StackFrame stackFrame = new System.Diagnostics.StackFrame();
System.Reflection.MethodBase methodBase = stackFrame.GetMethod();
log.Debug("Start: " + methodBase.Name);
int userId = 0; ;
try
{
string SessionToken = Convert.ToString(HttpContext.Current.Session["CSS2SessionID"]);
if (!string.IsNullOrEmpty(SessionToken) ? true : false)
{
// User session is Active Session it returns users id else returns 0
userId = UserLogin.CheckUserSessionToken(SessionToken);
}
}
catch (Exception ex)
{
log.Error("Error: " + ex);
}
log.Debug("End: " + methodBase.Name);
return userId;
}
示例9: AdhocActionOnDisbursementItems
public JsonResult AdhocActionOnDisbursementItems(string DisbursementIds, int Adhoc, string ForState)
{
System.Diagnostics.StackFrame stackFrame = new System.Diagnostics.StackFrame();
System.Reflection.MethodBase methodBase = stackFrame.GetMethod();
log.Debug("Start: " + methodBase.Name);
try
{
int checkSession = UserLogin.AuthenticateRequest();
if (checkSession == 0)
{
return Json(checkSession);
}
else
{
DisbursementItem objDisbursementItem = new DisbursementItem();
int result = objDisbursementItem.AdhocActionOnDisbursementItems(DisbursementIds, Adhoc, ForState, checkSession);
return Json(result);
}
}
catch (Exception ex)
{
log.Error("Error: " + ex);
return Json("");
}
finally
{
log.Debug("End: " + methodBase.Name);
}
}
示例10: tbl_genLog_Logger
public void tbl_genLog_Logger(int ID_hrStaff,int ID_reqpUserID, int ID_LogType, string RequestText = "",string SessionID = "", string LogText = "")
{
ServiceConfig srvcont = new ServiceConfig(_ServiceConfigParameters);
try
{
System.Diagnostics.StackFrame sf = new System.Diagnostics.StackFrame(1);
var method = sf.GetMethod();
string methodName = method.Name;
DateTime dNow = DateTime.Now;
Entities.tbl_genLog userlog = new Entities.tbl_genLog();
//LogType 3 = UserAction
userlog.ID_LogType = ID_LogType;
userlog.LogID = methodName;
userlog.ID_Staff = ID_reqpUserID;
userlog.SessionID = SessionID;
userlog.RequestText = RequestText;
userlog.LogText = LogText;
userlog.TS_CREATE = dNow;
userlog.VALID_FROM = dNow;
userlog.VALID_TO = dNow;
userlog.CREATED_BY = ID_hrStaff;
srvcont.DataContext.tbl_genLog.AddObject(userlog);
srvcont.DataContext.SaveChanges();
}
catch (Exception)
{
//no action
}
}
示例11: CABUpdateReceiveStatus
/// <summary>
/// Description : To Update Receive Status For Invoice From ACCPAC
/// Created By : Pavan
/// Created Date : 29 Oct 2014
/// Modified By :
/// Modified Date:
/// </summary>
public static int CABUpdateReceiveStatus(DataTable dtINVOICE_FROM_CSS2, DataTable dtINVOICE_DETAILS_FROM_CSS2)
{
int UpdateStatus = -2;
System.Diagnostics.StackFrame stackFrame = new System.Diagnostics.StackFrame();
System.Reflection.MethodBase methodBase = stackFrame.GetMethod();
log.Debug("Start: " + methodBase.Name);
try
{
SqlParameter[] sqlParams = new SqlParameter[2];
sqlParams[0] = new SqlParameter("@dtINVOICE_FROM_ACCPAC", dtINVOICE_FROM_CSS2);
sqlParams[0].SqlDbType = SqlDbType.Structured;
sqlParams[1] = new SqlParameter("@dtINVOICE_DETAILS_FROM_ACCPAC", dtINVOICE_DETAILS_FROM_CSS2);
sqlParams[1].SqlDbType = SqlDbType.Structured;
DataSet ds = SqlHelper.ExecuteDataset(ConnectionUtility.GetConnectionString(), CommandType.StoredProcedure, "SpCABUpdateReceiveStatus", sqlParams);
return UpdateStatus;
}
catch (Exception ex)
{
log.Error("Error: " + ex);
return UpdateStatus;
}
finally
{
log.Debug("End: " + methodBase.Name);
}
}
示例12: GetCSS1GroupDetails
/// <summary>
/// Description : Get the Group information from CSS1
/// Created By : Shiva
/// Created Date : 10 July 2014
/// Modified By :
/// Modified Date:
/// </summary>
/// <returns></returns>
public static GroupInfo GetCSS1GroupDetails()
{
var data = new GroupInfo();
System.Diagnostics.StackFrame stackFrame = new System.Diagnostics.StackFrame();
System.Reflection.MethodBase methodBase = stackFrame.GetMethod();
log.Debug("Start: " + methodBase.Name);
try
{
var lstGroupInfo = new List<GroupInfo>();
var reader = SqlHelper.ExecuteReader(ConnectionUtility.GetConnectionString(), CommandType.StoredProcedure, "SpGetCSS1GroupDetails");
var safe = new SafeDataReader(reader);
while (reader.Read())
{
var getGroupInfo = new GroupInfo();
getGroupInfo.FetchGroupInfo(getGroupInfo, safe);
lstGroupInfo.Add(getGroupInfo);
}
data.GroupInfoList = lstGroupInfo;
return data;
}
catch (Exception ex)
{
log.Error("Error: " + ex);
return data;
}
finally
{
log.Debug("End: " + methodBase.Name);
}
}
示例13: Css1InfoDetails
public JsonResult Css1InfoDetails(string WOID, string WOType)
{
System.Diagnostics.StackFrame stackFrame = new System.Diagnostics.StackFrame();
System.Reflection.MethodBase methodBase = stackFrame.GetMethod();
log.Debug("Start: " + methodBase.Name);
try
{
int checkSession = UserLogin.AuthenticateRequest();
if (checkSession == 0)
{
return Json(checkSession);
}
else
{
DataSet result = Masters.Models.Masters.Css1InfoDetail.GetCss1InfoDetails(WOID, WOType);
string data = JsonConvert.SerializeObject(result, Formatting.Indented);
return Json(data);
}
}
catch (Exception ex)
{
log.Error("Error: " + ex);
return Json("");
}
finally
{
log.Debug("End: " + methodBase.Name);
}
}
示例14: btnSave_Click
/// <summary>
/// 保存当前组用户
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSave_Click(object sender, EventArgs e)
{
try
{
UpdateTempUser();
string users = "-1,";
if (ViewState["hdnRowValue"].ToString().Length > 0)
users += ViewState["hdnRowValue"].ToString().Replace("'", "");
users += "-1";
BLL.BLLBase bll = new BLL.BLLBase();
bll.ExecNonQuery("Security.UpdateUserGroup", new DataParameter[] { new DataParameter("@GroupID", GroupID), new DataParameter("{0}", users) });
ScriptManager.RegisterClientScriptBlock(this.UpdatePanel1, this.UpdatePanel1.GetType(), "Resize", "Close('1');", true);
}
catch(Exception ex)
{
System.Diagnostics.StackFrame frame = new System.Diagnostics.StackFrame(0);
Session["ModuleName"] = this.Page.Title;
Session["FunctionName"] = frame.GetMethod().Name;
Session["ExceptionalType"] = ex.GetType().FullName;
Session["ExceptionalDescription"] = ex.Message;
Response.Redirect("../../../Common/MistakesPage.aspx");
}
}
示例15: ArrayAttribute
public ArrayAttribute(NsNode parent, XmlNode xml)
: this(parent, null, null)
{
if (!FromXml(xml))
{
System.Diagnostics.StackFrame stackFrame = new System.Diagnostics.StackFrame(1, true);
throw new AttributeXmlFormatException(this, xml, "Failed to read xml (" + stackFrame.GetMethod() + " ln: " + stackFrame.GetFileLineNumber() +")");
}
}