Exemple #1
0
    /// <summary>
    /// Inner wrapper for async operations
    /// </summary>
    /// <returns></returns>
    private async Task Execute_Async()
    {
        var azureGraphSession = AzureGetGraphSession();

        //===================================================================================
        //Get Groups that map to Tableau Site User Roles from Azure
        //===================================================================================
        _statusLogs.AddStatus("Azure: Getting user roles groups");
        await GenerateUsersRolesList_FromAzureGroupsSyncList(azureGraphSession, _configSyncGroups.GroupsToRolesSyncList);

        //===================================================================================
        //Get Groups that map to Tableau Site Groups from Azure
        //===================================================================================
        _statusLogs.AddStatus("Azure: Getting user roles groups");
        await GenerateGroupsMembersList_FromAzureGroupsSyncList(azureGraphSession, _configSyncGroups.GroupsToGroupsSyncList);

        //===================================================================================
        //Now perform any replace/override operations we need to based on explicit users
        //===================================================================================
        _statusLogs.AddStatus("Replacing any explicit user/role overrides");
        foreach (var thisOverrideUser in _configSyncGroups.UserRolesOverrideList)
        {
            SetManagerForRoles.AddAndForceReplaceUser(thisOverrideUser);
        }

        //Mark the work status as complete
        IsExecuteComplete.Trigger();
    }
Exemple #2
0
    /// <summary>
    /// Adds a set of users.  This is typically called when initializing this object.
    /// </summary>
    /// <param name="usersList"></param>
    internal void AddUsers(IEnumerable <SiteUser> usersList)
    {
        //If add users got called (even with 0 users) mark the group users as known
        _groupUsersKnown.Trigger();

        //Nothing to add?
        if (usersList == null)
        {
            return;
        }

        _usersInGroup.AddRange(usersList);
    }
Exemple #3
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="sb"></param>
    /// <param name="appendValue"></param>
    /// <param name="isFirstItem"></param>
    private static void AppendCSVValue(StringBuilder sb, string appendValue, SimpleLatch notFirstItem)
    {
        //Normalize the input
        if (appendValue == null)
        {
            appendValue = "";
        }

        //Add a preceeding comma if we are not the first item
        if (notFirstItem.Value)
        {
            sb.Append(",");
        }
        var escapedValue = appendValue;

        var needsQuoting = new SimpleLatch();

        escapedValue = ReplaceIfExists(escapedValue, "\"", "\"\"", needsQuoting); //Replace any single " with ""  (CSV convention)

        //escapedValue = escapedValue.Replace("\"", "\"\""); //Replace any single " with ""  (CSV convention)
        escapedValue = escapedValue.Replace("\n", " "); //Remove newlines
        escapedValue = escapedValue.Replace("\r", " "); //Remove carrage returns

        //If it has a comma it needs to be quoted
        if (escapedValue.Contains(","))
        {
            needsQuoting.Trigger();
        }
        //bool containsComma = escapedValue.Contains(",");

        if (needsQuoting.Value)
        {
            sb.Append("\"");
        }                                            //Start quote
        sb.Append(escapedValue);
        if (needsQuoting.Value)
        {
            sb.Append("\"");
        }                       //End quote
        notFirstItem.Trigger(); //No longer the first item
    }
Exemple #4
0
    /// <summary>
    /// Replace any 'find' with 'replace'.  Trigger the latch if a replace occured
    /// </summary>
    /// <param name="text"></param>
    /// <param name="find"></param>
    /// <param name="replace"></param>
    /// <param name="triggerIfFound"></param>
    /// <returns></returns>
    private static string ReplaceIfExists(string text, string find, string replace, SimpleLatch triggerIfFound)
    {
        if (text == null)
        {
            return("");
        }
        //
        if (text.IndexOf(find) == -1)
        {
            return(text);
        }

        //If there's text to replace, then replace it
        string outText = text.Replace(find, replace);

        //If the text changed, trigger the latch
        if (outText != text)
        {
            //Set the latch
            triggerIfFound.Trigger();
        }

        return(outText);
    }
    /// <summary>
    /// Replace any 'find' with 'replace'.  Trigger the latch if a replace occured
    /// </summary>
    /// <param name="text"></param>
    /// <param name="find"></param>
    /// <param name="replace"></param>
    /// <param name="triggerIfFound"></param>
    /// <returns></returns>
    private static string ReplaceIfExists(string text, string find, string replace, SimpleLatch triggerIfFound)
    {
        if (text == null) return "";
        //
        if(text.IndexOf(find) == -1)
        {
            return text;
        }

        //If there's text to replace, then replace it
        string outText = text.Replace(find, replace);

        //If the text changed, trigger the latch
        if (outText != text)
        {
            //Set the latch
            triggerIfFound.Trigger();
        }

        return outText;
    }
    /// <summary>
    /// 
    /// </summary>
    /// <param name="sb"></param>
    /// <param name="appendValue"></param>
    /// <param name="isFirstItem"></param>
    private static void AppendCSVValue(StringBuilder sb, string appendValue, SimpleLatch notFirstItem)
    {
        //Normalize the input
        if (appendValue == null)
        {
            appendValue = "";
        }

        //Add a preceeding comma if we are not the first item
        if (notFirstItem.Value)
        {
            sb.Append(",");
        }
        var escapedValue = appendValue;

        var needsQuoting = new SimpleLatch();
        escapedValue = ReplaceIfExists(escapedValue, "\"", "\"\"", needsQuoting); //Replace any single " with ""  (CSV convention)

        //escapedValue = escapedValue.Replace("\"", "\"\""); //Replace any single " with ""  (CSV convention)
        escapedValue = escapedValue.Replace("\n", " "); //Remove newlines
        escapedValue = escapedValue.Replace("\r", " "); //Remove carrage returns

        //If it has a comma it needs to be quoted
        if(escapedValue.Contains(","))
        {
            needsQuoting.Trigger();
        }
        //bool containsComma = escapedValue.Contains(",");

        if (needsQuoting.Value) { sb.Append("\""); } //Start quote
        sb.Append(escapedValue);
        if (needsQuoting.Value) { sb.Append("\""); } //End quote
        notFirstItem.Trigger(); //No longer the first item
    }
Exemple #7
0
 /// <summary>
 /// Signals that the keep alive thread should go away
 /// </summary>
 public void ExitAsync()
 {
     _exitThreadLatch.Trigger(); //Tells the background thread to stop running.
 }