本文整理汇总了C#中EventSource.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# EventSource.ToString方法的具体用法?C# EventSource.ToString怎么用?C# EventSource.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EventSource
的用法示例。
在下文中一共展示了EventSource.ToString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Log
public void Log(EventSource eventSource, Exception exception, EventId eventId, EventLogEntryType logEntryType)
{
if (!EventLog.SourceExists(eventSource.ToString()))
{
EventLog.CreateEventSource(eventSource.ToString(), "TrainSurfer");
}
EventLog log = new EventLog();
log.Source = eventSource.ToString();
log.WriteEntry(FormatException(exception), logEntryType, (int)eventId);
}
示例2: CreateEvent
public int CreateEvent (EventSource eventSource, EventType eventType, int actingPersonId,
int organizationId,
int geographyId, int affectedPersonId, int parameterInt, string parameterText,
DateTime processTime)
{
using (DbConnection connection = GetMySqlDbConnection())
{
connection.Open();
DbCommand command = GetDbCommand("CreatePWEvent", connection);
command.CommandType = CommandType.StoredProcedure;
AddParameterWithName(command, "eventSource", eventSource.ToString());
AddParameterWithName(command, "eventType", eventType.ToString());
AddParameterWithName(command, "actingPersonId", actingPersonId);
AddParameterWithName(command, "organizationId", organizationId);
AddParameterWithName(command, "geographyId", geographyId);
AddParameterWithName(command, "affectedPersonId", affectedPersonId);
AddParameterWithName(command, "parameterInt", parameterInt);
AddParameterWithName(command, "parameterText", parameterText);
AddParameterWithName(command, "processDateTime", processTime);
return Convert.ToInt32(command.ExecuteScalar());
}
}
示例3: Terminate
//public void Terminate ()
//{
// Terminate(EventSource.Unknown);
//}
public void Terminate (EventSource eventSource, Person actingPerson, string description)
{
if (base.Active)
{
//Added removal of Roles here to make SURE they always are removed with the membership.
Authority authority = Person.GetAuthority();
int actingPersonId = actingPerson == null ? 0 : actingPerson.Identity;
BasicPersonRole[] roles = authority.AllPersonRoles;
List<PersonRole> theRoles = new List<PersonRole>();
foreach (BasicPersonRole basicRole in roles)
{
PersonRole personRole = PersonRole.FromBasic(basicRole);
theRoles.Add(personRole);
if (personRole.OrganizationId == OrganizationId)
{
PWEvents.CreateEvent(eventSource, EventType.DeletedRole, actingPersonId,
personRole.OrganizationId, personRole.GeographyId,
Person.Identity, (int)personRole.Type,
string.Empty);
PWLog.Write(actingPersonId, PWLogItem.Person, Person.Identity, PWLogAction.RoleDeleted,
"Role " + personRole.Type.ToString() + " of " + personRole.Geography.Name +
" was deleted with membership.", string.Empty);
personRole.Delete();
}
}
//now check if this means that you no longer are a member of some uplevel org, then remove those roles as well
foreach (PersonRole personRole in theRoles)
{
if (!this.Person.MemberOfWithInherited(personRole.Organization))
{
PWEvents.CreateEvent(eventSource, EventType.DeletedRole, actingPersonId,
personRole.OrganizationId, personRole.GeographyId,
Person.Identity, (int)personRole.Type,
string.Empty);
PWLog.Write(actingPersonId, PWLogItem.Person, Person.Identity, PWLogAction.RoleDeleted,
"Role " + personRole.Type.ToString() + " of " + personRole.Geography.Name +
" was deleted with membership of all suborgs.", string.Empty);
personRole.Delete();
}
}
EventSource src = EventSource.PirateWeb;
try
{
if (HttpContext.Current == null)
{
src = EventSource.PirateBot;
}
}
catch
{
src = EventSource.PirateBot;
}
PWLog.Write(actingPersonId, PWLogItem.Person, Person.Identity, PWLogAction.MemberLost,
eventSource.ToString() + ":" + description, string.Empty);
PWEvents.CreateEvent(src, EventType.LostMember, actingPersonId, this.OrganizationId, Person.GeographyId,
Person.Identity, 0, OrganizationId.ToString());
//Added LogChurn here to make SURE they always are logged with the membership.
if (PersonId > 0 && this.OrganizationId > 0 && base.Expires != new DateTime(1900, 1, 1))
{
ChurnData.LogChurn(this.PersonId, this.OrganizationId);
}
SwarmDb.GetDatabaseForWriting().TerminateMembership(Identity);
base.Active = false;
base.DateTerminated = DateTime.Now;
// Remove all newsletter subscriptions once the membership is terminated (to make sure default is now off and only turn off explicitly turned-on subscriptions)
// HACK HACK HACK: uses feed IDs in an extremely ugly way to loop 1-9. Should use NewsletterFeeds.ForOrganization() once support for newsletters in different orgs are established.
for (int newsletterFeedId = 1; newsletterFeedId < 10; newsletterFeedId++)
{
try
{
if (person.IsSubscribing(newsletterFeedId))
{
person.SetSubscription(newsletterFeedId, false);
}
}
catch (Exception)
{
// ignore nonexisting newsletter feeds -- this is a hack anyway
}
}
}
}