示例#1
0
    private void VoteForEntry(AgentPrivate admin, AgentPrivate agent)
    {
        string message = "Kick and ban " + agent.AgentInfo.Name + " ?";

        try
        {
            ModalDialog modalDialog = admin.Client.UI.ModalDialog;
            modalDialog.Show(message, "Yes", "No", (OperationCompleteEvent opc) =>
            {
                if (modalDialog.Response == "Yes")
                {
                    kicks = kicks + 1;
                    if (DebugLogging)
                    {
                        Log.Write(admin.AgentInfo.Name + " voted to ban " + agent.AgentInfo.Name);
                    }
                }
                else
                {
                    keeps = keeps + 1;
                    if (DebugLogging)
                    {
                        Log.Write(admin.AgentInfo.Name + " voted to keep " + agent.AgentInfo.Name);
                    }
                }
            });

            Wait(TimeSpan.FromSeconds(VoteTime));

            modalDialog.Cancel();

            if (DebugLogging)
            {
                Log.Write("kicks " + kicks + " keeps " + keeps);
            }
            if (kicks > keeps)
            {
                BanUser(agent);
            }
            else
            {
                if (DebugLogging)
                {
                    Log.Write("Voted to keep " + agent.AgentInfo.Name);
                }
            }
        }
        catch (Exception e)
        {
            if (DebugLogging)
            {
                Log.Write("Voting Exception: " + e);
            }
        }
    }