/// <summary>
        /// ClientEventForm - for creating new client event record
        /// </summary>
        /// <param name="mainForm">main form</param>
        public ClientEventForm(MainForm mainForm)
        {
            _clientEvent = new ClientEventModel();
            _clientsEvents_TrackWorkers = new List <ClientEvents_TrackWorkersModel>();
            _mainForm = mainForm;
            InitializeComponent();

            btnEnter.Click += btnClientEventAdd_Click;
        }
예제 #2
0
        public Task GuildAvailable(DiscordClient client, GuildCreateEventArgs e)
        {
            var clientEventModel = new ClientEventModel
            {
                GuildName = e.Guild.Name,
                GuildId   = e.Guild.Id,
            };

            (string message, object[] args) = clientEventModel.ToEventLogTuple(message: "Guild available.");

            client.Logger.LogInformation(DockordEventId.BotClientGuildAvailable, message, args);

            return(Task.CompletedTask);
        }
예제 #3
0
        public Task ClientErrored(DiscordClient client, ClientErrorEventArgs e)
        {
            var clientEventModel = new ClientEventModel
            {
                Username          = client.CurrentUser.Username,
                UserDiscriminator = client.CurrentUser?.Discriminator,
                UserId            = client.CurrentUser?.Id,
            };

            (string message, object[] args) = clientEventModel.ToEventLogTuple(message: "Discord client error occurred.");

            client.Logger.LogError(DockordEventId.BotClientError, e.Exception, message, args);

            return(Task.CompletedTask);
        }
예제 #4
0
        public async Task <IActionResult> GetClientEvent(string eventId, string viewId)
        {
            EventModel vEvent = await _eventDataManager.GetEvent(eventId, true);

            ClientEventModel clientEvent = new ClientEventModel()
            {
                Id              = vEvent.Id,
                EventName       = vEvent.EventName,
                EventLocations  = vEvent.EventLocations,
                EventSentiments = vEvent.EventSentiments,
                EventView       = vEvent.EventViews?.Find(p => p.ViewId == viewId),
                IsEventActive   = vEvent.IsEventActive,
                LastNote        = vEvent.LastNote
            };

            return(Ok(clientEvent));
        }
        /// <summary>
        /// UpdateClientEvent - update record of client event
        /// </summary>
        /// <param name="updatedClientEvent">updated client event</param>
        /// <param name="id">client event id</param>
        /// <returns>bool true or false</returns>
        public static bool UpdateClientEvent(ClientEventModel updatedClientEvent, int id)
        {
            using (SQLiteConnection cnn = new SQLiteConnection(LoadConnectionString()))
            {
                var ReturnVal = 0;
                cnn.Open();

                string sqlStatement = "UPDATE ClientEvents SET [ClientID] = @updatedClientId, [TrackID] = @updatedTrackId, [Date] = @updatedDate, "
                                      + "[WorkersRequested] = @updatedWorkersRequested, [IsLunchProvided] = @updatedIsLunchProvided, "
                                      + "[IsUsingUpperPaddock] = @updatedisUsingUpperPaddock, [IsUsingMiddlePaddock] = @updatedisUsingMiddlePaddock, "
                                      + "[IsUsingLowerPaddock] = @updatedisUsingLowerPaddock, [WorkerCalloutSent] = @updatedWorkerCalloutSent, "
                                      + "[RequireSafetyDemo] = @updatedRequireSafetyDemo, [IsDeleted] = @updatedIsDeleted "
                                      + "WHERE [ClientEventID] = @id";

                var cmd = new SQLiteCommand(sqlStatement, cnn);
                cmd.Parameters.AddWithValue("@updatedClientId", updatedClientEvent.ClientID);
                cmd.Parameters.AddWithValue("@updatedTrackId", updatedClientEvent.TrackID);
                cmd.Parameters.AddWithValue("@updatedDate", updatedClientEvent.Date);
                cmd.Parameters.AddWithValue("@updatedWorkersRequested", updatedClientEvent.WorkersRequested);
                cmd.Parameters.AddWithValue("@updatedIsLunchProvided", updatedClientEvent.IsLunchProvided);
                cmd.Parameters.AddWithValue("@updatedisUsingUpperPaddock", updatedClientEvent.IsUsingUpperPaddock);
                cmd.Parameters.AddWithValue("@updatedisUsingMiddlePaddock", updatedClientEvent.IsUsingMiddlePaddock);
                cmd.Parameters.AddWithValue("@updatedisUsingLowerPaddock", updatedClientEvent.IsUsingLowerPaddock);
                cmd.Parameters.AddWithValue("@updatedWorkerCalloutSent", updatedClientEvent.WorkerCalloutSent);
                cmd.Parameters.AddWithValue("@updatedRequireSafetyDemo", updatedClientEvent.RequireSafetyDemo);
                cmd.Parameters.AddWithValue("@updatedIsDeleted", updatedClientEvent.IsDeleted);

                cmd.Parameters.AddWithValue("@id", id);

                try
                {
                    cmd.Prepare();
                    ReturnVal = cmd.ExecuteNonQuery();
                }
                catch (SQLiteException ex)
                {
                    throw ex;
                }
                finally
                {
                    cnn.Close();
                }
                return(ReturnVal == 1);
            }
        }
        /// <summary>
        /// SaveClientEvent -  save a new record of client event
        /// </summary>
        /// <param name="clientEvent">new client event</param>
        public static void SaveClientEvent(ClientEventModel clientEvent, List <ClientEvents_TrackWorkersModel> clientsEvents_TrackWorkersList)
        {
            using (SQLiteConnection cnn = new SQLiteConnection(LoadConnectionString()))
            {
                cnn.Open();
                string sqlStatement = "INSERT INTO ClientEvents(ClientID, TrackID, Date, WorkersRequested, IsLunchProvided, "
                                      + "IsUsingUpperPaddock, IsUsingMiddlePaddock, IsUsingLowerPaddock, WorkerCalloutSent, RequireSafetyDemo, "
                                      + "IsDeleted) VALUES( @clientId, @trackId, @date, @workerRequested, @isLunchProvided, @isUsingUpperPaddock, "
                                      + "@isUsingMiddlePaddock, @isUsingLowerPaddock, @workerCalloutSent, @requireSafetyDemo, @isDeleted )";

                var cmd = new SQLiteCommand(sqlStatement, cnn);
                cmd.Parameters.AddWithValue("@clientId", clientEvent.ClientID);
                cmd.Parameters.AddWithValue("@trackId", clientEvent.TrackID);
                cmd.Parameters.AddWithValue("@date", clientEvent.Date);
                cmd.Parameters.AddWithValue("@workerRequested", clientEvent.WorkersRequested);
                cmd.Parameters.AddWithValue("@isLunchProvided", clientEvent.IsLunchProvided);
                cmd.Parameters.AddWithValue("@isUsingUpperPaddock", clientEvent.IsUsingUpperPaddock);
                cmd.Parameters.AddWithValue("@isUsingMiddlePaddock", clientEvent.IsUsingMiddlePaddock);
                cmd.Parameters.AddWithValue("@isUsingLowerPaddock", clientEvent.IsUsingLowerPaddock);
                cmd.Parameters.AddWithValue("@workerCalloutSent", clientEvent.WorkerCalloutSent);
                cmd.Parameters.AddWithValue("@requireSafetyDemo", clientEvent.RequireSafetyDemo);
                // HARD CODED FALSE
                cmd.Parameters.AddWithValue("@isDeleted", false);

                try
                {
                    cmd.Prepare();
                    cmd.ExecuteNonQuery();
                }
                catch (SQLiteException ex)
                {
                    throw ex;
                }
                try
                {
                    ClientEvents_TrackWorkersDataAccess.SaveClientEventTrackWorker(clientsEvents_TrackWorkersList, cnn);
                }
                finally
                {
                    cnn.Close();
                }
            }
        }
예제 #7
0
        public ValidDiscordEventModels()
        {
            IDiscordEvent validCmdEventModel = new CommandEventModel
            {
                CommandName       = _commandName,
                CommandArgs       = $"{_channelName} 90",
                Username          = _username,
                UserDiscriminator = _userDiscriminator,
                UserId            = _userId,
                ChannelName       = _channelName,
                ChannelId         = _channelId,
                IsDirectMessage   = false,
                GuildName         = _guildName,
                GuildId           = _guildId,
            };

            Add(validCmdEventModel);

            IDiscordEvent directMessageCmdEventModel = new CommandEventModel
            {
                CommandName       = "help",
                CommandArgs       = _commandName,
                Username          = _username,
                UserDiscriminator = _userDiscriminator,
                UserId            = _userId,
                ChannelId         = _channelId,
                IsDirectMessage   = true,
            };

            Add(directMessageCmdEventModel);

            IDiscordEvent noUserData = new CommandEventModel
            {
                CommandName     = _commandName,
                CommandArgs     = $"{_channelName} 90",
                ChannelName     = _channelName,
                ChannelId       = _channelId,
                IsDirectMessage = false,
                GuildName       = _guildName,
                GuildId         = _guildId,
            };

            Add(noUserData);

            IDiscordEvent noCommandName = new CommandEventModel
            {
                Username          = _username,
                UserDiscriminator = _userDiscriminator,
                UserId            = _userId,
                ChannelId         = _channelId,
                IsDirectMessage   = true,
            };

            Add(noCommandName);

            IDiscordEvent nullUsername = new CommandEventModel
            {
                CommandName     = _commandName,
                CommandArgs     = $"{_channelName} 90",
                ChannelName     = _channelName,
                ChannelId       = _channelId,
                IsDirectMessage = false,
                GuildName       = _guildName,
                GuildId         = _guildId,
                Username        = null !,
            };

            Add(nullUsername);

            IDiscordEvent nullCommandName = new CommandEventModel
            {
                CommandName       = null !,
                Username          = _username,
                UserDiscriminator = _userDiscriminator,
                UserId            = _userId,
                ChannelId         = _channelId,
                IsDirectMessage   = true,
            };

            Add(nullCommandName);

            IDiscordEvent whitespaceUsername = new CommandEventModel
            {
                CommandName     = _commandName,
                CommandArgs     = $"{_channelName} 90",
                ChannelName     = _channelName,
                ChannelId       = _channelId,
                IsDirectMessage = false,
                GuildName       = _guildName,
                GuildId         = _guildId,
                Username        = "******",
            };

            Add(whitespaceUsername);

            IDiscordEvent whitespaceCommandName = new CommandEventModel
            {
                CommandName       = " ",
                Username          = _username,
                UserDiscriminator = _userDiscriminator,
                UserId            = _userId,
                ChannelId         = _channelId,
                IsDirectMessage   = true,
            };

            Add(whitespaceCommandName);

            IDiscordEvent validClientEventModel = new ClientEventModel
            {
                Username          = _username,
                UserDiscriminator = _userDiscriminator,
                UserId            = _userId,
            };

            Add(validClientEventModel);

            IDiscordEvent guildClientEventModel = new ClientEventModel
            {
                Username          = _username,
                UserDiscriminator = _userDiscriminator,
                UserId            = _userId,
                GuildName         = _guildName,
                GuildId           = _guildId,
            };

            Add(guildClientEventModel);
        }
    }
예제 #8
0
        /// <summary>
        /// SetWebBrowserTable - for creating html mail
        /// </summary>
        public void SetWebBrowserTable()
        {
            List <ClientEventModel> clientEventModelsList = new List <ClientEventModel>();

            allClientEventTrackWorkerIdList = new List <int>();
            foreach (int clientEventId in _clientEventIdList)
            {
                ClientEventModel clientEvent = ClientEventDataAccess.LoadClientEvent(clientEventId);
                clientEvent.TrackWorkersId      = ClientEvents_TrackWorkersDataAccess.LoadClientEventTrackWorkerIDList(clientEventId);
                allClientEventTrackWorkerIdList = allClientEventTrackWorkerIdList.Union(clientEvent.TrackWorkersId).ToList();
                clientEventModelsList.Add(clientEvent);
            }

            stringBodyHTML += "<table style=\"border: 1px solid black;text-align:center;\">";
            stringBodyHTML += "<tr>";
            stringBodyHTML += "<td></td>";
            foreach (ClientEventModel clientEvent in clientEventModelsList)
            {
                ClientModel client = ClientDataAccess.LoadClient(clientEvent.ClientID);
                stringBodyHTML += "<td style=\"border: 1px solid black;\">" + client.Name + "</td>";
            }
            stringBodyHTML += "</tr>";
            stringBodyHTML += "<tr>";
            stringBodyHTML += "<td></td>";
            foreach (ClientEventModel clientEvent in clientEventModelsList)
            {
                stringBodyHTML += "<td style=\"border: 1px solid black;\">" + clientEvent.Date + "</td>";
            }
            stringBodyHTML += "</tr>";
            stringBodyHTML += "<tr>";
            stringBodyHTML += "<td style=\"border: 1px solid black;\"># Workers Needed</td>";
            foreach (ClientEventModel clientEvent in clientEventModelsList)
            {
                stringBodyHTML += "<td style=\"border: 1px solid black;\">" + clientEvent.WorkersRequested + "</td>";
            }
            stringBodyHTML += "</tr>";
            stringBodyHTML += "<tr>";
            stringBodyHTML += "<td style=\"border: 1px solid black;\">Track</td>";
            foreach (ClientEventModel clientEvent in clientEventModelsList)
            {
                TrackModel track = TrackDataAccess.LoadTrack(clientEvent.TrackID);
                stringBodyHTML += "<td style=\"border: 1px solid black;\">" + track.Name + "</td>";
            }
            stringBodyHTML += "</tr>";

            stringBodyHTML += "<tr><td><b>Worker Name</b></td></tr>";
            foreach (int trackWorkerId in allClientEventTrackWorkerIdList)
            {
                stringBodyHTML += "<tr>";
                TrackWorkerModel trackWorker = TrackWorkerDataAccess.LoadTrackWorker(trackWorkerId);
                stringBodyHTML += "<td style=\"border: 1px solid black;\">" + trackWorker.FullName() + "</td>";
                foreach (ClientEventModel clientEvent in clientEventModelsList)
                {
                    if (clientEvent.TrackWorkersId.Contains(trackWorkerId))
                    {
                        stringBodyHTML += "<td style=\"border: 1px solid black;\">X</td>";
                    }
                    else
                    {
                        stringBodyHTML += "<td style=\"border: 1px solid black;\">&nbsp;</td>";
                    }
                }
                stringBodyHTML += "</tr>";
            }
            stringBodyHTML += "</table>";

            //webBrowser.DocumentText += stringTableHTML;
        }
예제 #9
0
        /// <summary>
        /// dgvClientEvent_CellClick - client event cell click event for updating
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dgvClientEvent_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex >= 0)
            {
                ClientEventModel clientEventModel = new ClientEventModel();
                clientEventModel.ClientEventID    = int.Parse(dgvClientEvent.Rows[e.RowIndex].Cells["ClientEventID"].Value.ToString());
                clientEventModel.ClientID         = int.Parse(dgvClientEvent.Rows[e.RowIndex].Cells["ClientID"].Value.ToString());
                clientEventModel.TrackID          = int.Parse(dgvClientEvent.Rows[e.RowIndex].Cells["TrackID"].Value.ToString());
                clientEventModel.Date             = dgvClientEvent.Rows[e.RowIndex].Cells["Date"].Value.ToString();
                clientEventModel.WorkersRequested = int.Parse(dgvClientEvent.Rows[e.RowIndex].Cells["WorkersRequested"].Value.ToString());

                if (dgvClientEvent.Rows[e.RowIndex].Cells["IsLunchProvided"].Value.ToString() == "True")
                {
                    clientEventModel.IsLunchProvided = true;
                }
                else
                {
                    clientEventModel.IsLunchProvided = false;
                }

                if (dgvClientEvent.Rows[e.RowIndex].Cells["IsUsingUpperPaddock"].Value.ToString() == "True")
                {
                    clientEventModel.IsUsingUpperPaddock = true;
                }
                else
                {
                    clientEventModel.IsUsingUpperPaddock = false;
                }

                if (dgvClientEvent.Rows[e.RowIndex].Cells["IsUsingMiddlePaddock"].Value.ToString() == "True")
                {
                    clientEventModel.IsUsingMiddlePaddock = true;
                }
                else
                {
                    clientEventModel.IsUsingMiddlePaddock = false;
                }

                if (dgvClientEvent.Rows[e.RowIndex].Cells["IsUsingLowerPaddock"].Value.ToString() == "True")
                {
                    clientEventModel.IsUsingLowerPaddock = true;
                }
                else
                {
                    clientEventModel.IsUsingLowerPaddock = false;
                }

                if (dgvClientEvent.Rows[e.RowIndex].Cells["WorkerCalloutSent"].Value.ToString() == "True")
                {
                    clientEventModel.WorkerCalloutSent = true;
                }
                else
                {
                    clientEventModel.WorkerCalloutSent = false;
                }

                if (dgvClientEvent.Rows[e.RowIndex].Cells["RequireSafetyDemo"].Value.ToString() == "True")
                {
                    clientEventModel.RequireSafetyDemo = true;
                }
                else
                {
                    clientEventModel.RequireSafetyDemo = false;
                }

                if (dgvClientEvent.Rows[e.RowIndex].Cells["IsDeleted"].Value.ToString() == "True")
                {
                    clientEventModel.IsDeleted = true;
                }
                else
                {
                    clientEventModel.IsDeleted = false;
                }
                ClientEventForm tracksForm = new ClientEventForm(this, clientEventModel);
                tracksForm.ShowDialog();
            }
        }
        /// <summary>
        /// ClientEventForm - for updating client event record
        /// </summary>
        /// <param name="mainForm">main form</param>
        /// <param name="clientEventModel">client event record</param>
        public ClientEventForm(MainForm mainForm, ClientEventModel clientEventModel)
        {
            _mainForm = mainForm;
            InitializeComponent();
            btnEnter.Click += btnClientEventUpdate_Click;

            btnEnter.Text = "&Update";

            // load client event data to the form
            _clientEvent = clientEventModel;
            ClientModel clientModel = ClientDataAccess.LoadClient(_clientEvent.ClientID);
            TrackModel  trackModel  = TrackDataAccess.LoadTrack(_clientEvent.TrackID);

            _clientsEvents_TrackWorkers = ClientEvents_TrackWorkersDataAccess.LoadClientEventTrackWorker(clientEventModel.ClientEventID);

            txtClientEventId.Text = clientEventModel.ClientEventID.ToString();
            txtClientId.Text      = clientModel.Name.ToString();
            txtTrackID.Text       = trackModel.Name.ToString();

            txtClientEventDate.Text = _clientEvent.Date.ToString();
            txtWorkerRequested.Text = _clientEvent.WorkersRequested.ToString();
            if (_clientEvent.IsLunchProvided)
            {
                rdoClientEventIsLunchProvided_True.Checked = true;
            }
            else
            {
                rdoClientEventIsLunchProvided_False.Checked = true;
            }

            if (_clientEvent.IsUsingUpperPaddock)
            {
                cbClientEventIsUsingUpperPaddock.Checked = true;
            }
            else
            {
                cbClientEventIsUsingUpperPaddock.Checked = false;
            }

            if (_clientEvent.IsUsingMiddlePaddock)
            {
                cbClientEventIsUsingMiddlePaddock.Checked = true;
            }
            else
            {
                cbClientEventIsUsingMiddlePaddock.Checked = false;
            }

            if (_clientEvent.IsUsingLowerPaddock)
            {
                cbClientEventIsUsingLowerPaddock.Checked = true;
            }
            else
            {
                cbClientEventIsUsingLowerPaddock.Checked = false;
            }

            if (_clientEvent.WorkerCalloutSent)
            {
                rdoClientEventWorkerCalloutSent_True.Checked = true;
            }
            else
            {
                rdoClientEventWorkerCalloutSent_False.Checked = true;
            }

            if (_clientEvent.RequireSafetyDemo)
            {
                rdoClientEventRequireSafetyDemo_True.Checked = true;
            }
            else
            {
                rdoClientEventRequireSafetyDemo_False.Checked = true;
            }

            if (_clientEvent.IsDeleted)
            {
                rdoClientEventIsDeleted_Disabled.Checked = true;
            }
            else
            {
                rdoClientEventIsDeleted_Enabled.Checked = true;
            }
        }