Пример #1
0
        public static async Task <List <PrivateLog> > GetAllLogData()
        {
            HttpResponseMessage response = await client.GetAsync(CreateQueryString(Properties.Resources.ProjectID, QueryType.GetAll, "logs"));

            if (response.IsSuccessStatusCode)
            {
                Debug.WriteLine("Successful");
                string json = response.Content.ReadAsStringAsync().Result;
                Dictionary <string, PrivateLogDTO> data = JsonConvert.DeserializeObject <Dictionary <string, PrivateLogDTO> >(json);
                List <PrivateLog> logs = new List <PrivateLog>();

                foreach (var item in data.Values.ToList())
                {
                    PrivateLog pl = new PrivateLog(item);
                    pl.Message = Decrypt(pl.Message, Keys.PrivateKey);
                    logs.Add(pl);
                }
                return(logs);
            }
            else
            {
                Debug.WriteLine("Unsuccessful");
                return(null);
            }
        }
Пример #2
0
        static void MenuOptions_GetLog()
        {
            Console.Write("Please enter ID of Log:");
            string     id  = Console.ReadLine();
            PrivateLog dto = JMS_Commands.GetLog(id);

            if (dto != null)
            {
                PrintLog(dto);
            }
            else
            {
                Console.WriteLine("No Results.");
            }
        }
Пример #3
0
        static void MenuOptions_UpdateLog()
        {
            Console.Write("Please enter the id of the log item you would like to update:");
            PrivateLog log = JMS_Commands.GetLog(Console.ReadLine());

            Console.Write("Log to update:");
            PrintLog(log);

            Console.Write("Please enter updated log message:");
            log.Message = Console.ReadLine();

            JMS_Commands.CreateLog(new PrivateLogDTO(log));

            log = null;
            GC.Collect();
        }
Пример #4
0
        public static async Task <PrivateLog> GetLogData(string id)
        {
            HttpResponseMessage response = await client.GetAsync(CreateQueryString(Properties.Resources.ProjectID, QueryType.Get, "logs", id));

            if (response.IsSuccessStatusCode)
            {
                Debug.WriteLine("Successful");
                string        json = response.Content.ReadAsStringAsync().Result;
                PrivateLogDTO data = JsonConvert.DeserializeObject <PrivateLogDTO>(json);
                PrivateLog    log  = new PrivateLog(data);
                log.Message = Decrypt(log.Message, Keys.PrivateKey);
                return(log);
            }
            else
            {
                Debug.WriteLine("Unsuccessful");
                return(null);
            }
        }
Пример #5
0
 public static void PrintLog(PrivateLog dto)
 {
     Console.ForegroundColor = ConsoleColor.Green;
     Console.WriteLine($"ID:{dto.ID} - User ID:{dto.UserID} - Message:{dto.Message}");
     Console.ForegroundColor = ConsoleColor.White;
 }
Пример #6
0
 public void InvokePrivateLog(string message) => PrivateLog?.Invoke(new LogEvent(game, message));