private void RunTest()
 {
     for (int i = 0; i < 50; i++)
     {
         Thread.Sleep(100);
         LogContext.AppendLine("Sample log " + i);
     }
 }
Example #2
0
    /// <summary>
    /// Adds the log information.
    /// </summary>
    /// <param name="newLog">New log information</param>
    protected bool AddLog(string newLog)
    {
        EnsureLog();
        AddEventLog(newLog);
        LogContext.AppendLine(newLog);

        return(true);
    }
Example #3
0
    /// <summary>
    /// Delete items.
    /// </summary>
    private void DeleteActivities(IWhereCondition whereCondition)
    {
        var activitiesToDelete = ActivityInfoProvider.GetActivities()
                                 .Columns("ActivityID", "ActivityType", "ActivityTitle")
                                 .Where(whereCondition);

        foreach (var activity in activitiesToDelete)
        {
            LogContext.AppendLine(string.Format("{0} - {1}", activity.ActivityTitle, activity.ActivityType));
            ActivityInfoProvider.DeleteActivityInfo(activity);
        }
    }
Example #4
0
 /// <summary>
 /// Adds the log information
 /// </summary>
 /// <param name="newLog">New log information</param>
 /// <param name="addWholeLine">Indicates if log text forms whole line</param>
 protected void AddLog(string newLog, bool addWholeLine)
 {
     EnsureLog();
     if (addWholeLine)
     {
         LogContext.AppendLine(newLog);
     }
     else
     {
         LogContext.Append(newLog);
     }
 }
Example #5
0
    /// <summary>
    /// Adds the log error.
    /// </summary>
    /// <param name="newLog">New log information</param>
    /// <param name="errorMessage">Error message</param>
    protected void AddErrorLog(string newLog, string errorMessage)
    {
        LogContext.AppendLine(newLog, "Integration");

        string logMessage = newLog;

        if (errorMessage != null)
        {
            logMessage = errorMessage + "<br />" + logMessage;
        }
        eventType = EventType.ERROR;

        AddEventLog(logMessage);
    }
Example #6
0
    /// <summary>
    /// Adds the log error.
    /// </summary>
    /// <param name="newLog">New log information</param>
    /// <param name="errorMessage">Error message</param>
    protected void AddErrorLog(string newLog, string errorMessage)
    {
        LogContext.AppendLine(newLog);

        string logMessage = newLog;

        if (errorMessage != null)
        {
            logMessage = errorMessage + "<br />" + logMessage;
        }
        eventType = EventLogProvider.EVENT_TYPE_ERROR;

        AddEventLog(logMessage);
    }
    /// <summary>
    ///  Delete items.
    /// </summary>
    private void DeleteItems(string whereCondition)
    {
        DataSet ds = GetData(whereCondition, "ActivityID", "ActivityID, ActivityType, ActivityTitle");

        if (!DataHelper.DataSourceIsEmpty(ds))
        {
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                string activityTitle = ValidationHelper.GetString(dr["ActivityTitle"], null);
                string activityType  = ValidationHelper.GetString(dr["ActivityType"], null);
                int    activityId    = ValidationHelper.GetInteger(dr["ActivityID"], 0);
                LogContext.AppendLine(activityTitle + " - " + activityType);
                ActivityInfoProvider.DeleteActivityInfo(activityId);
            }
        }
    }
Example #8
0
 /// <summary>
 /// Adds the log information
 /// </summary>
 /// <param name="newLog">New log information</param>
 protected void AddLog(string newLog)
 {
     EnsureLog();
     LogContext.AppendLine(newLog);
 }
Example #9
0
 /// <summary>
 /// Adds the error to collection of errors.
 /// </summary>
 /// <param name="error">Error message</param>
 protected void AddError(string error)
 {
     EnsureLog();
     LogContext.AppendLine(error);
     CurrentError = (error + "<br />" + CurrentError);
 }
Example #10
0
 /// <summary>
 /// Adds the log information.
 /// </summary>
 /// <param name="newLog">New log information</param>
 private void AddLog(string newLog)
 {
     EnsureLog();
     LogContext.AppendLine(newLog);
 }
Example #11
0
 /// <summary>
 /// Adds the log error.
 /// </summary>
 /// <param name="newLog">New log information</param>
 /// <param name="errorMessage">Error message</param>
 protected void AddErrorLog(string newLog, string errorMessage)
 {
     LogContext.AppendLine(newLog);
 }
    /// <summary>
    /// Refreshes the security parameters in macros for all the objects of the specified object types.
    /// Signs all the macros with the current user if the old salt is not specified.
    /// </summary>
    /// <param name="objectTypes">Object types</param>
    /// <param name="oldSalt">Old salt </param>
    /// <param name="newSalt">New salt</param>
    private void RefreshSecurityParams(IEnumerable <string> objectTypes, string oldSalt, string newSalt)
    {
        var oldSaltSpecified = !string.IsNullOrEmpty(oldSalt) && !chkRefreshAll.Checked;
        var newSaltSpecified = !string.IsNullOrEmpty(newSalt) && !chkUseCurrentSalt.Checked;

        processedObjects.Clear();

        using (CMSActionContext context = new CMSActionContext())
        {
            context.LogEvents          = false;
            context.LogSynchronization = false;

            foreach (var objectType in objectTypes)
            {
                var objectTypeResourceKey = TypeHelper.GetObjectTypeResourceKey(objectType);
                var niceObjectType        = GetString(objectTypeResourceKey);
                if (niceObjectType == objectTypeResourceKey)
                {
                    if (objectType.StartsWithCSafe("bizformitem.bizform.", true))
                    {
                        DataClassInfo dci = DataClassInfoProvider.GetDataClass(objectType.Substring("bizformitem.".Length));
                        if (dci != null)
                        {
                            niceObjectType = "on-line form " + dci.ClassDisplayName;
                        }
                    }
                    else
                    {
                        niceObjectType = objectType;
                    }
                }

                LogContext.AppendLine(string.Format(GetString("macros.refreshsecurityparams.processing"), niceObjectType));

                try
                {
                    var infos = InfoObjectCollection.New(objectType);
                    foreach (var info in infos)
                    {
                        bool refreshed = false;
                        if (oldSaltSpecified)
                        {
                            refreshed = MacroResolver.RefreshSecurityParameters(info, oldSalt, newSaltSpecified ? newSalt : ValidationHelper.HashStringSalt, true);
                        }
                        else
                        {
                            if (chkRefreshAll.Checked && newSaltSpecified)
                            {
                                // Do not check integrity, but use new salt
                                refreshed = MacroResolver.RefreshSecurityParameters(info, CMSContext.CurrentUser.UserName, true, newSalt);
                            }
                            else
                            {
                                // Do not check integrity, sign everything with current user, current salt
                                refreshed = MacroResolver.RefreshSecurityParameters(info, CMSContext.CurrentUser.UserName, true);
                            }
                        }

                        if (refreshed)
                        {
                            var objectName = HTMLHelper.HTMLEncode(ResHelper.LocalizeString(info.Generalized.ObjectDisplayName));
                            processedObjects.Add(niceObjectType, objectName);
                        }
                    }
                }
                catch (Exception e)
                {
                    LogContext.AppendLine(e.Message);
                    EventLogProvider.LogException(EVENTLOG_SOURCE_REFRESHSECURITYPARAMS, "ERROR", e);
                }
            }
        }

        EventLogProvider.LogInformation(EVENTLOG_SOURCE_REFRESHSECURITYPARAMS, "PROCESSEDOBJECTS", GetProcessedObjectsForEventLog());
    }