本文整理汇总了C#中DotNetNuke.Services.Log.EventLog.LogInfo.AddProperty方法的典型用法代码示例。如果您正苦于以下问题:C# LogInfo.AddProperty方法的具体用法?C# LogInfo.AddProperty怎么用?C# LogInfo.AddProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DotNetNuke.Services.Log.EventLog.LogInfo
的用法示例。
在下文中一共展示了LogInfo.AddProperty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpgradeModule
private static void UpgradeModule(EventMessage message)
{
try
{
int desktopModuleId = Convert.ToInt32(message.Attributes["DesktopModuleId"]);
var desktopModule = DesktopModuleController.GetDesktopModule(desktopModuleId, Null.NullInteger);
string BusinessControllerClass = message.Attributes["BusinessControllerClass"];
object controller = Reflection.CreateObject(BusinessControllerClass, "");
if (controller is IUpgradeable)
{
//get the list of applicable versions
string[] UpgradeVersions = message.Attributes["UpgradeVersionsList"].Split(',');
foreach (string Version in UpgradeVersions)
{
//call the IUpgradeable interface for the module/version
string Results = ((IUpgradeable) controller).UpgradeModule(Version);
//log the upgrade results
var log = new LogInfo {LogTypeKey = EventLogController.EventLogType.MODULE_UPDATED.ToString()};
log.AddProperty("Module Upgraded", BusinessControllerClass);
log.AddProperty("Version", Version);
if (!string.IsNullOrEmpty(Results))
{
log.AddProperty("Results", Results);
}
LogController.Instance.AddLog(log);
}
}
UpdateSupportedFeatures(controller, Convert.ToInt32(message.Attributes["DesktopModuleId"]));
}
catch (Exception exc)
{
Exceptions.LogException(exc);
}
}
示例2: GetConfig
public static RewriterConfiguration GetConfig()
{
var config = new RewriterConfiguration {Rules = new RewriterRuleCollection()};
FileStream fileReader = null;
string filePath = "";
try
{
config = (RewriterConfiguration) DataCache.GetCache("RewriterConfig");
if ((config == null))
{
filePath = Common.Utilities.Config.GetPathToFile(Common.Utilities.Config.ConfigFileType.SiteUrls);
//Create a FileStream for the Config file
fileReader = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read);
var doc = new XPathDocument(fileReader);
config = new RewriterConfiguration {Rules = new RewriterRuleCollection()};
foreach (XPathNavigator nav in doc.CreateNavigator().Select("RewriterConfig/Rules/RewriterRule"))
{
var rule = new RewriterRule {LookFor = nav.SelectSingleNode("LookFor").Value, SendTo = nav.SelectSingleNode("SendTo").Value};
config.Rules.Add(rule);
}
if (File.Exists(filePath))
{
//Set back into Cache
DataCache.SetCache("RewriterConfig", config, new DNNCacheDependency(filePath));
}
}
}
catch (Exception ex)
{
//log it
var objEventLog = new EventLogController();
var objEventLogInfo = new LogInfo();
objEventLogInfo.AddProperty("UrlRewriter.RewriterConfiguration", "GetConfig Failed");
objEventLogInfo.AddProperty("FilePath", filePath);
objEventLogInfo.AddProperty("ExceptionMessage", ex.Message);
objEventLogInfo.LogTypeKey = EventLogController.EventLogType.HOST_ALERT.ToString();
objEventLog.AddLog(objEventLogInfo);
Logger.Error(objEventLogInfo);
}
finally
{
if (fileReader != null)
{
//Close the Reader
fileReader.Close();
}
}
return config;
}
示例3: UpgradeApplication
///-----------------------------------------------------------------------------
///<summary>
/// UpgradeApplication - This overload is used for general application upgrade operations.
///</summary>
///<remarks>
/// Since it is not version specific and is invoked whenever the application is
/// restarted, the operations must be re-executable.
///</remarks>
///<history>
/// [cnurse] 11/6/2004 documented
/// [cnurse] 02/27/2007 made public so it can be called from Wizard
///</history>
///-----------------------------------------------------------------------------
public static void UpgradeApplication()
{
try
{
//Remove UpdatePanel from Login Control - not neccessary in popup.
var loginControl = ModuleControlController.GetModuleControlByControlKey("Login", -1);
loginControl.SupportsPartialRendering = false;
ModuleControlController.SaveModuleControl(loginControl, true);
//Upgrade to .NET 3.5/4.0
TryUpgradeNETFramework();
//Update the version of the client resources - so the cache is cleared
DataCache.ClearHostCache(false);
HostController.Instance.IncrementCrmVersion(true);
}
catch (Exception ex)
{
Logger.Error(ex);
var log = new LogInfo
{
LogTypeKey = EventLogController.EventLogType.HOST_ALERT.ToString(),
BypassBuffering = true
};
log.AddProperty("Upgraded DotNetNuke", "General");
log.AddProperty("Warnings", "Error: " + ex.Message + Environment.NewLine);
LogController.Instance.AddLog(log);
try
{
Exceptions.Exceptions.LogException(ex);
}
catch (Exception exc)
{
Logger.Error(exc);
}
}
//Remove any .txt and .config files that may exist in the Install folder
foreach (string file in Directory.GetFiles(Globals.InstallMapPath + "Cleanup\\", "??.??.??.txt"))
{
FileSystemUtils.DeleteFile(file);
}
foreach (string file in Directory.GetFiles(Globals.InstallMapPath + "Config\\", "??.??.??.config"))
{
FileSystemUtils.DeleteFile(file);
}
}
示例4: OnPreRequestHandlerExecute
private void OnPreRequestHandlerExecute(object sender, EventArgs e)
{
try
{
//First check if we are upgrading/installing or if it is a non-page request
var app = (HttpApplication) sender;
HttpRequest request = app.Request;
//First check if we are upgrading/installing
if (request.Url.LocalPath.ToLower().EndsWith("install.aspx")
|| request.Url.LocalPath.ToLower().Contains("upgradewizard.aspx")
|| request.Url.LocalPath.ToLower().Contains("installwizard.aspx"))
{
return;
}
//exit if a request for a .net mapping that isn't a content page is made i.e. axd
if (request.Url.LocalPath.ToLower().EndsWith(".aspx") == false && request.Url.LocalPath.ToLower().EndsWith(".asmx") == false &&
request.Url.LocalPath.ToLower().EndsWith(".ashx") == false)
{
return;
}
if (HttpContext.Current != null)
{
HttpContext context = HttpContext.Current;
if ((context == null))
{
return;
}
var page = context.Handler as CDefault;
if ((page == null))
{
return;
}
page.Load += OnPageLoad;
}
}
catch (Exception ex)
{
var objEventLog = new EventLogController();
var objEventLogInfo = new LogInfo();
objEventLogInfo.AddProperty("Analytics.AnalyticsModule", "OnPreRequestHandlerExecute");
objEventLogInfo.AddProperty("ExceptionMessage", ex.Message);
objEventLogInfo.LogTypeKey = EventLogController.EventLogType.HOST_ALERT.ToString();
objEventLog.AddLog(objEventLogInfo);
Logger.Error(objEventLogInfo);
}
}
示例5: LogModuleProviderExceptionInRequest
/// <summary>
/// logs an exception related to a module provider once per cache-lifetime
/// </summary>
/// <param name="ex"></param>
/// <param name="status"></param>
/// <param name="result"></param>
/// <param name="messages"></param>
/// <param name="provider"></param>
public static void LogModuleProviderExceptionInRequest(Exception ex, string status,
ExtensionUrlProvider provider,
UrlAction result,
List<string> messages)
{
if (ex != null)
{
string moduleProviderName = "Unknown Provider";
string moduleProviderVersion = "Unknown Version";
if (provider != null)
{
moduleProviderName = provider.ProviderConfig.ProviderName;
moduleProviderVersion = provider.GetType().Assembly.GetName(false).Version.ToString();
}
//this logic prevents a site logging an exception for every request made. Instead
//the exception will be logged once for the life of the cache / application restart or 1 hour, whichever is shorter.
//create a cache key for this exception type
string cacheKey = ex.GetType().ToString();
//see if there is an existing object logged for this exception type
object existingEx = DataCache.GetCache(cacheKey);
if (existingEx == null)
{
//if there was no existing object logged for this exception type, this is a new exception
DateTime expire = DateTime.Now.AddHours(1);
DataCache.SetCache(cacheKey, cacheKey, expire);
//just store the cache key - it doesn't really matter
//create a log event
string productVer = Assembly.GetExecutingAssembly().GetName(false).Version.ToString();
var elc = new EventLogController();
var logEntry = new LogInfo {LogTypeKey = "GENERAL_EXCEPTION"};
logEntry.AddProperty("Url Rewriting Extension Url Provider Exception",
"Exception in Url Rewriting Process");
logEntry.AddProperty("Provider Name", moduleProviderName);
logEntry.AddProperty("Provider Version", moduleProviderVersion);
logEntry.AddProperty("Http Status", status);
logEntry.AddProperty("Product Version", productVer);
if (result != null)
{
logEntry.AddProperty("Original Path", result.OriginalPath ?? "null");
logEntry.AddProperty("Raw Url", result.RawUrl ?? "null");
logEntry.AddProperty("Final Url", result.FinalUrl ?? "null");
logEntry.AddProperty("Rewrite Result", !string.IsNullOrEmpty(result.RewritePath)
? result.RewritePath
: "[no rewrite]");
logEntry.AddProperty("Redirect Location", string.IsNullOrEmpty(result.FinalUrl)
? "[no redirect]"
: result.FinalUrl);
logEntry.AddProperty("Action", result.Action.ToString());
logEntry.AddProperty("Reason", result.Reason.ToString());
logEntry.AddProperty("Portal Id", result.PortalId.ToString());
logEntry.AddProperty("Tab Id", result.TabId.ToString());
logEntry.AddProperty("Http Alias", result.PortalAlias != null ? result.PortalAlias.HTTPAlias : "Null");
if (result.DebugMessages != null)
{
int i = 1;
foreach (string debugMessage in result.DebugMessages)
{
string msg = debugMessage;
if (debugMessage == null)
{
msg = "[message was null]";
}
logEntry.AddProperty("Debug Message[result] " + i.ToString(), msg);
i++;
}
}
}
else
{
logEntry.AddProperty("Result", "Result value null");
}
if (messages != null)
{
int i = 1;
foreach (string msg in messages)
{
logEntry.AddProperty("Debug Message[raw] " + i.ToString(), msg);
i++;
}
}
logEntry.AddProperty("Exception Type", ex.GetType().ToString());
logEntry.AddProperty("Message", ex.Message);
logEntry.AddProperty("Stack Trace", ex.StackTrace);
if (ex.InnerException != null)
{
logEntry.AddProperty("Inner Exception Message", ex.InnerException.Message);
logEntry.AddProperty("Inner Exception Stacktrace", ex.InnerException.StackTrace);
}
logEntry.BypassBuffering = true;
elc.AddLog(logEntry);
//.........这里部分代码省略.........
示例6: InvalidateDictionary
public static void InvalidateDictionary(string reason, PageIndexData rebuildData, int portalId)
{
//if supplied, store the rebuildData for when the dictionary gets rebuilt
//this is a way of storing data between dictionary rebuilds
if (rebuildData != null)
{
DataCache.SetCache("rebuildData", rebuildData);
}
//add log entry for cache clearance
var elc = new EventLogController();
var logValue = new LogInfo { LogTypeKey = "HOST_ALERT" };
try
{
//817 : not clearing items correctly from dictionary
CacheController.FlushPageIndexFromCache();
}
catch (Exception ex)
{
//do nothing ; can be from trying to access cache after system restart
Services.Exceptions.Exceptions.LogException(ex);
}
logValue.AddProperty("Url Rewriting Caching Message", "Page Index Cache Cleared. Reason: " + reason);
logValue.AddProperty("Thread Id", Thread.CurrentThread.ManagedThreadId.ToString());
elc.AddLog(logValue);
}
示例7: RestartApplication
protected virtual void RestartApplication()
{
var objEv = new EventLogController();
var objEventLogInfo = new LogInfo { BypassBuffering = true, LogTypeKey = EventLogController.EventLogType.HOST_ALERT.ToString() };
objEventLogInfo.AddProperty("Message", GetString("UserRestart"));
objEv.AddLog(objEventLogInfo);
Config.Touch();
}
示例8: GetConfigFile
/// -----------------------------------------------------------------------------
/// <summary>
/// Retrieves the Google Analytics config file, "SiteAnalytics.config".
/// </summary>
/// <returns></returns>
/// <remarks>
/// </remarks>
/// <history>
/// [vnguyen] 10/08/2010 Created
/// </history>
/// -----------------------------------------------------------------------------
private StreamReader GetConfigFile()
{
StreamReader fileReader = null;
string filePath = "";
try
{
filePath = Globals.ApplicationMapPath + "\\SiteAnalytics.config";
if (File.Exists(filePath))
{
fileReader = new StreamReader(filePath);
}
}
catch (Exception ex)
{
//log it
var objEventLog = new EventLogController();
var objEventLogInfo = new LogInfo();
objEventLogInfo.AddProperty("GoogleAnalytics.UpgradeModule", "GetConfigFile Failed");
objEventLogInfo.AddProperty("FilePath", filePath);
objEventLogInfo.AddProperty("ExceptionMessage", ex.Message);
objEventLogInfo.LogTypeKey = EventLogController.EventLogType.HOST_ALERT.ToString();
objEventLog.AddLog(objEventLogInfo);
fileReader.Close();
Logger.Error(ex);
}
return fileReader;
}
示例9: LogResult
private void LogResult(string message)
{
var log = new LogInfo
{
LogPortalID = PortalSettings.PortalId,
LogPortalName = PortalSettings.PortalName,
LogUserID = UserId
};
if (string.IsNullOrEmpty(message))
{
log.LogTypeKey = "PASSWORD_SENT_SUCCESS";
}
else
{
log.LogTypeKey = "PASSWORD_SENT_FAILURE";
log.LogProperties.Add(new LogDetailInfo("Cause", message));
}
log.AddProperty("IP", _ipAddress);
LogController.Instance.AddLog(log);
}
示例10: ProcessMessages
/// <summary>
/// Processes the messages.
/// </summary>
/// <param name="eventMessages">The event messages.</param>
/// <returns></returns>
public static bool ProcessMessages(EventMessageCollection eventMessages)
{
bool success = Null.NullBoolean;
EventMessage message;
for (int messageNo = 0; messageNo <= eventMessages.Count - 1; messageNo++)
{
message = eventMessages[messageNo];
try
{
object oMessageProcessor = Reflection.CreateObject(message.ProcessorType, message.ProcessorType);
if (!((EventMessageProcessorBase) oMessageProcessor).ProcessMessage(message))
{
throw new Exception();
}
//Set Message comlete so it is not run a second time
DataProvider.Instance().SetEventMessageComplete(message.EventMessageID);
success = true;
}
catch
{
//log if message could not be processed
var objEventLog = new EventLogController();
var objEventLogInfo = new LogInfo();
objEventLogInfo.AddProperty("EventQueue.ProcessMessage", "Message Processing Failed");
objEventLogInfo.AddProperty("ProcessorType", message.ProcessorType);
objEventLogInfo.AddProperty("Body", message.Body);
objEventLogInfo.AddProperty("Sender", message.Sender);
foreach (string key in message.Attributes.Keys)
{
objEventLogInfo.AddProperty(key, message.Attributes[key]);
}
if (!String.IsNullOrEmpty(message.ExceptionMessage))
{
objEventLogInfo.AddProperty("ExceptionMessage", message.ExceptionMessage);
}
objEventLogInfo.LogTypeKey = EventLogController.EventLogType.HOST_ALERT.ToString();
objEventLog.AddLog(objEventLogInfo);
if (message.ExpirationDate < DateTime.Now)
{
//Set Message comlete so it is not run a second time
DataProvider.Instance().SetEventMessageComplete(message.EventMessageID);
}
}
}
return success;
}
示例11: LogResult
private void LogResult(string message)
{
var portalSecurity = new PortalSecurity();
var objEventLog = new EventLogController();
var objEventLogInfo = new LogInfo();
objEventLogInfo.AddProperty("IP", _ipAddress);
objEventLogInfo.LogPortalID = PortalSettings.PortalId;
objEventLogInfo.LogPortalName = PortalSettings.PortalName;
objEventLogInfo.LogUserID = UserId;
// objEventLogInfo.LogUserName = portalSecurity.InputFilter(txtUsername.Text,
// PortalSecurity.FilterFlag.NoScripting | PortalSecurity.FilterFlag.NoAngleBrackets | PortalSecurity.FilterFlag.NoMarkup);
if (string.IsNullOrEmpty(message))
{
objEventLogInfo.LogTypeKey = "PASSWORD_SENT_SUCCESS";
}
else
{
objEventLogInfo.LogTypeKey = "PASSWORD_SENT_FAILURE";
objEventLogInfo.LogProperties.Add(new LogDetailInfo("Cause", message));
}
objEventLog.AddLog(objEventLogInfo);
}
示例12: RestartApplication
protected virtual void RestartApplication()
{
var log = new LogInfo { BypassBuffering = true, LogTypeKey = EventLogController.EventLogType.HOST_ALERT.ToString() };
log.AddProperty("Message", GetString("UserRestart"));
LogController.Instance.AddLog(log);
Config.Touch();
}
示例13: GetLogFromXPath
private LogInfoArray GetLogFromXPath( string xpath, string PortalID, string LogType, int PageSize, int PageIndex, ref int TotalRecords )
{
XmlDocument xmlConfigDoc = GetConfigDoc();
ArrayList arrLogFiles = GetLogFiles( xmlConfigDoc, PortalID, LogType );
XmlDocument xmlLogFiles = new XmlDocument();
xmlLogFiles.LoadXml( "<LogCollection></LogCollection>" );
XmlElement xmlLogFilesDocEl;
xmlLogFilesDocEl = xmlLogFiles.DocumentElement;
ArrayList arrLogInfo = new ArrayList();
int i;
for( i = 0; i <= arrLogFiles.Count - 1; i++ )
{
bool FileIsCorrupt = false;
bool FileExists = true;
string LogFile;
LogFile = Convert.ToString( arrLogFiles[i] );
XmlDocument xmlLogFile = new XmlDocument();
try
{
lockLog.AcquireReaderLock( ReaderLockTimeout );
xmlLogFile.Load( LogFile );
}
catch( FileNotFoundException )
{
FileExists = false;
//file doesn't exist
}
catch( XmlException )
{
FileExists = false;
FileIsCorrupt = true;
//file is corrupt
}
finally
{
lockLog.ReleaseReaderLock();
}
if( FileIsCorrupt )
{
string s = "A log file is corrupt '" + LogFile + "'.";
if (LogFile.IndexOf( "Exceptions.xml.resources", 0) > 0)
{
s += " This could be due to an older exception log file being written to by the new logging provider. Try removing 'Exceptions.xml.resources' from the logs directory to solve the problem.";
}
LogInfo objEventLogInfo = new LogInfo();
objEventLogInfo.AddProperty( "Note", s );
objEventLogInfo.BypassBuffering = true;
objEventLogInfo.LogTypeKey = "HOST_ALERT";
EventLogController objEventLog = new EventLogController();
objEventLog.AddLog( objEventLogInfo );
}
else if( FileExists )
{
XmlNodeList xmlNodes;
xmlNodes = xmlLogFile.SelectNodes( xpath );
XmlElement xmlLogNodes;
xmlLogNodes = xmlLogFiles.CreateElement( "logs" );
XmlNode xmlNode;
foreach( XmlNode tempLoopVar_xmlNode in xmlNodes )
{
xmlNode = tempLoopVar_xmlNode;
xmlLogNodes.AppendChild( xmlLogFiles.ImportNode( xmlNode, true ) );
}
xmlLogFilesDocEl.AppendChild( xmlLogNodes );
}
}
return GetLogInfoFromXML( xmlLogFiles, PageSize, PageIndex, ref TotalRecords );
}
示例14: SendLogNotifications
//--------------------------------------------------------------
//Method to send email notifications
//--------------------------------------------------------------
public override void SendLogNotifications()
{
try
{
lockNotif.AcquireWriterLock( WriterLockTimeout );
XmlDocument xmlPendingNotificationsDoc = new XmlDocument();
try
{
xmlPendingNotificationsDoc.Load( GetFilePath( PendingNotificationsFile ) );
}
catch( FileNotFoundException )
{
//file not found
return;
}
ArrayList arrLogTypeInfo;
XMLLoggingProvider x = new XMLLoggingProvider();
arrLogTypeInfo = x.GetLogTypeConfigInfo();
PurgeLogBuffer();
int a;
for( a = 0; a <= arrLogTypeInfo.Count - 1; a++ )
{
LogTypeConfigInfo objLogTypeInfo;
objLogTypeInfo = (LogTypeConfigInfo)arrLogTypeInfo[a];
if( objLogTypeInfo.EmailNotificationIsActive )
{
XmlNodeList xmlPendingNotifications = xmlPendingNotificationsDoc.DocumentElement.SelectNodes( "log[@NotificationLogTypeKey='" + objLogTypeInfo.LogTypeKey + "' and @LogTypePortalID='" + objLogTypeInfo.LogTypePortalID + "' and number(@LogCreateDateNum) > " + DateToNum( objLogTypeInfo.StartDateTime ).ToString() + "]" );
if( xmlPendingNotifications.Count >= objLogTypeInfo.NotificationThreshold )
{
//we have notifications to send out
XmlNode xmlPendingNotification;
XmlDocument xmlOut = new XmlDocument();
xmlOut.LoadXml( "<notification></notification>" );
foreach( XmlNode tempLoopVar_xmlPendingNotification in xmlPendingNotifications )
{
xmlPendingNotification = tempLoopVar_xmlPendingNotification;
XmlNode tmpNode;
tmpNode = xmlOut.ImportNode( xmlPendingNotification, true );
xmlOut.DocumentElement.AppendChild( tmpNode );
//Remove the node from the list of pending notifications
xmlPendingNotificationsDoc.DocumentElement.RemoveChild( xmlPendingNotification );
}
bool NotificationFailed = false;
string errSendNotif;
errSendNotif = Mail.Mail.SendMail( objLogTypeInfo.MailFromAddress, objLogTypeInfo.MailToAddress, "", "Log Notification", xmlOut.OuterXml, "", "", "", "", "", "" );
if( !String.IsNullOrEmpty(errSendNotif) )
{
//notification failed to send
NotificationFailed = true;
}
EventLogController objEventLogController = new EventLogController();
if( NotificationFailed )
{
//Notification failed, log it
LogInfo objEventLogInfo = new LogInfo();
objEventLogInfo.LogTypeKey = EventLogController.EventLogType.LOG_NOTIFICATION_FAILURE.ToString();
objEventLogInfo.AddProperty( "Log Notification Failed: ", errSendNotif );
objEventLogController.AddLog( objEventLogInfo );
//need to reload the xml doc because
//we removed xml nodes above
xmlPendingNotificationsDoc.Load( GetFilePath( PendingNotificationsFile ) );
if( xmlPendingNotificationsDoc.DocumentElement.Attributes["LastNotificationFailure"] == null )
{
XmlAttribute xmlNotificationFailed;
xmlNotificationFailed = xmlPendingNotificationsDoc.CreateAttribute( "LastNotificationFailure" );
xmlNotificationFailed.Value = DateTime.Now.ToString();
xmlPendingNotificationsDoc.DocumentElement.Attributes.Append( xmlNotificationFailed );
}
else
{
xmlPendingNotificationsDoc.DocumentElement.Attributes["LastNotificationFailure"].Value = DateTime.Now.ToString();
}
xmlPendingNotificationsDoc.Save( GetFilePath( PendingNotificationsFile ) );
}
else
{
//Notification succeeded.
//Save the updated pending notifications file
//so we remove the notifications that have been completed.
if( xmlPendingNotificationsDoc.DocumentElement.Attributes["LastNotificationFailure"] != null )
{
xmlPendingNotificationsDoc.DocumentElement.Attributes.Remove( xmlPendingNotificationsDoc.DocumentElement.Attributes["LastNotificationFailure"] );
}
//.........这里部分代码省略.........
示例15: cmdSendPassword_Click
/// <summary>
/// cmdSendPassword_Click runs when the Password Reminder button is clicked
/// </summary>
/// <remarks>
/// </remarks>
/// <history>
/// [cnurse] 03/21/2006 Created
/// </history>
protected void cmdSendPassword_Click( Object sender, EventArgs e )
{
string strMessage = Null.NullString;
bool canSend = true;
if( ( UseCaptcha && ctlCaptcha.IsValid ) || ( ! UseCaptcha ) )
{
if( txtUsername.Text.Trim() != "" )
{
PortalSecurity objSecurity = new PortalSecurity();
UserInfo objUser = UserController.GetUserByName( PortalSettings.PortalId, txtUsername.Text, false );
if( objUser != null )
{
if( MembershipProviderConfig.PasswordRetrievalEnabled )
{
try
{
objUser.Membership.Password = UserController.GetPassword( ref objUser, txtAnswer.Text );
}
catch( Exception )
{
canSend = false;
strMessage = Localization.GetString( "PasswordRetrievalError", this.LocalResourceFile );
}
}
else
{
canSend = false;
strMessage = Localization.GetString( "PasswordRetrievalDisabled", this.LocalResourceFile );
}
if( canSend )
{
try
{
Mail.SendMail( objUser, MessageType.PasswordReminder, PortalSettings );
strMessage = Localization.GetString( "PasswordSent", this.LocalResourceFile );
}
catch( Exception )
{
canSend = false;
}
}
}
else
{
strMessage = Localization.GetString( "UsernameError", this.LocalResourceFile );
canSend = false;
}
if( canSend )
{
EventLogController objEventLog = new EventLogController();
LogInfo objEventLogInfo = new LogInfo();
objEventLogInfo.AddProperty( "IP", ipAddress );
objEventLogInfo.LogPortalID = PortalSettings.PortalId;
objEventLogInfo.LogPortalName = PortalSettings.PortalName;
objEventLogInfo.LogUserID = UserId;
objEventLogInfo.LogUserName = objSecurity.InputFilter( txtUsername.Text, PortalSecurity.FilterFlag.NoScripting | PortalSecurity.FilterFlag.NoAngleBrackets | PortalSecurity.FilterFlag.NoMarkup );
objEventLogInfo.LogTypeKey = "PASSWORD_SENT_SUCCESS";
objEventLog.AddLog( objEventLogInfo );
UI.Skins.Skin.AddModuleMessage( this, strMessage, ModuleMessageType.GreenSuccess );
}
else
{
EventLogController objEventLog = new EventLogController();
LogInfo objEventLogInfo = new LogInfo();
objEventLogInfo.AddProperty( "IP", ipAddress );
objEventLogInfo.LogPortalID = PortalSettings.PortalId;
objEventLogInfo.LogPortalName = PortalSettings.PortalName;
objEventLogInfo.LogUserID = UserId;
objEventLogInfo.LogUserName = objSecurity.InputFilter( txtUsername.Text, PortalSecurity.FilterFlag.NoScripting | PortalSecurity.FilterFlag.NoAngleBrackets | PortalSecurity.FilterFlag.NoMarkup );
objEventLogInfo.LogTypeKey = "PASSWORD_SENT_FAILURE";
objEventLog.AddLog( objEventLogInfo );
UI.Skins.Skin.AddModuleMessage( this, strMessage, ModuleMessageType.RedError );
}
}
else
{
strMessage = Localization.GetString( "EnterUsername", this.LocalResourceFile );
UI.Skins.Skin.AddModuleMessage( this, strMessage, ModuleMessageType.RedError );
}
}
}