Exemplo n.º 1
0
        /// <summary>
        /// Delete the specified ticket
        /// </summary>
        /// <param name="plr"></param>
        /// <param name="values"></param>
        /// <returns></returns>
        public static bool DeleteTicket(Player plr, ref List <string> values)
        {
            if (values.Count < 1)
            {
                plr.SendClientMessage("Usage: .ticket deleteticket <bugtrackerID>");
                return(true);
            }

            string reportID = GetTotalString(ref values).Trim();

            if (string.IsNullOrEmpty(reportID))
            {
                plr.SendClientMessage("you need to specify the ticketID");
                return(true);
            }

            Bug_report report = CharMgr.GetReport(reportID);

            if (report == null)
            {
                plr.SendClientMessage("The Specified report does not exist");
                return(true);
            }

            if (report.Assigned != plr.Client._Account.Username)
            {
                plr.SendClientMessage("You cannot close a ticket not assigned to you(username), assign it to yourself first if you fixed the ticket");
                return(true);
            }

            else
            {
                plr.SendClientMessage("You have deleted ticket: " + reportID);

                GMCommandLog log = new GMCommandLog
                {
                    PlayerName = plr.Client._Account.Username,
                    AccountId  = (uint)plr.Client._Account.AccountId,
                    Command    = $"Removed Ticket: {reportID} from characterID: {report.CharacterId}. containing the following message: {report.Message} {report.FieldSting}",
                    Date       = DateTime.Now
                };

                CharMgr.Database.AddObject(log);

                lock (CharMgr._report)
                {
                    CharMgr._report.Remove(report);
                    CharMgr.Database.DeleteObject(report);
                    CharMgr.Database.ForceSave();
                }
                return(true);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Assigns a person to a ticket
        /// </summary>
        /// <param name="plr"></param>
        /// <param name="values"></param>
        /// <returns></returns>
        public static bool Assign(Player plr, ref List <string> values)
        {
            if (values.Count < 2)
            {
                plr.SendClientMessage("Usage: .ticket assign <accountname> <bugtrackerID>");
                return(true);
            }

            string account  = GetString(ref values);
            string reportID = GetTotalString(ref values).Trim();

            if (string.IsNullOrEmpty(account))
            {
                plr.SendClientMessage("you need to specify a person for the ticket");
                return(true);
            }

            if (string.IsNullOrEmpty(reportID))
            {
                plr.SendClientMessage("you need to specify the ticketID");
                return(true);
            }

            Bug_report report = CharMgr.GetReport(reportID);

            if (report == null)
            {
                plr.SendClientMessage("The Specified report does not exist");
                return(true);
            }

            else
            {
                if (account == "nobody")
                {
                    plr.SendClientMessage("You have unassigned yourself from ticket: " + reportID);
                }
                else
                {
                    plr.SendClientMessage("You have assigned " + account + " to ticket: " + reportID);
                }

                lock (CharMgr._report)
                {
                    report.Assigned = account;
                    CharMgr.Database.SaveObject(report);
                    CharMgr.Database.ForceSave();
                }
                return(true);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// assigns the current player as the person responsible for the ticket
        /// </summary>
        /// <param name="plr"></param>
        /// <param name="values"></param>
        /// <returns></returns>
        public static bool AssignMe(Player plr, ref List <string> values)
        {
            if (values.Count < 1)
            {
                plr.SendClientMessage("Usage: .ticket assignme <bugtrackerID>");
                return(true);
            }

            string reportID = GetTotalString(ref values).Trim();

            if (string.IsNullOrEmpty(reportID))
            {
                plr.SendClientMessage("you need to specify the ticketID");
                return(true);
            }

            Bug_report report = CharMgr.GetReport(reportID);

            if (report == null)
            {
                plr.SendClientMessage("The Specified report does not exist");
                return(true);
            }

            else
            {
                plr.SendClientMessage("You have assigned yourself to ticket: " + reportID);
                lock (CharMgr._report)
                {
                    report.Assigned = plr.Client._Account.Username;
                    CharMgr.Database.SaveObject(report);
                    CharMgr.Database.ForceSave();
                }
                return(true);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// To answer and close a ticket (answer will be sent as an ingame mail)
        /// </summary>
        /// <param name="plr"></param>
        /// <param name="values"></param>
        /// <returns></returns>
        public static bool Answer(Player plr, ref List <string> values)
        {
            if (values.Count < 2)
            {
                plr.SendClientMessage("Usage: .ticket answer <bugtrackerID> <message>");
                return(true);
            }

            string reportID = GetString(ref values);
            string message  = GetTotalString(ref values).Trim();

            if (string.IsNullOrEmpty(message))
            {
                plr.SendClientMessage("you need to specify a message to send");
                return(true);
            }

            if (string.IsNullOrEmpty(reportID))
            {
                plr.SendClientMessage("you need to specify the ticketID");
                return(true);
            }

            Bug_report report = CharMgr.GetReport(reportID);

            if (report == null)
            {
                plr.SendClientMessage("The Specified report does not exist");
                return(true);
            }

            if (report.Assigned != plr.Client._Account.Username)
            {
                plr.SendClientMessage("You cannot answer a ticket not assigned to you(username), assign it to yourself first if you want to answer this ticket");
                return(true);
            }

            if (CharMgr.GetCharacter(report.CharacterId, false) == null)
            {
                plr.SendClientMessage("The player who created this ticket is deleted or has not logged in for over the preload period, as such we cannot send a mail to the character.");
                return(true);
            }

            else
            {
                plr.SendClientMessage("You have answered ticket: " + reportID);

                GMCommandLog log = new GMCommandLog
                {
                    PlayerName = plr.Client._Account.Username,
                    AccountId  = (uint)plr.Client._Account.AccountId,
                    Command    = $"Answered Ticket: {reportID} from characterID: {report.CharacterId}. Containing message: {report.Message} {report.FieldSting} with the following reply: {message}",
                    Date       = DateTime.Now
                };

                Character      chara      = CharMgr.GetCharacter(report.CharacterId, false);
                Character_mail ticketMail = new Character_mail
                {
                    Guid              = CharMgr.GenerateMailGuid(),
                    CharacterId       = chara.CharacterId,
                    CharacterIdSender = chara.CharacterId,
                    SenderName        = chara.Name,
                    ReceiverName      = chara.Name,
                    SendDate          = (uint)TCPManager.GetTimeStamp(),
                    Title             = "Answered Ticket",
                    Content           = $"Your ticket has been answered by: {report.Assigned} with the following message: \n \n {message}",
                    Money             = 0,
                    Opened            = false
                };

                CharMgr.AddMail(ticketMail);
                CharMgr.Database.AddObject(log);

                lock (CharMgr._report)
                {
                    CharMgr._report.Remove(report);
                    CharMgr.Database.DeleteObject(report);
                    CharMgr.Database.ForceSave();
                }
                return(true);
            }
        }