private static void Main(string[] args) { Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("Gang of Four Design Pattern - Adapter"); var xmlConverter = new XmlConverter(); var jsonConverter = new JsonConverter(UniversityDataService.GetUniversityData()); Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("XML Data Representation"); Console.WriteLine(xmlConverter.GetXml()); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("**************************************************************************************"); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("JSON Data Representation"); Console.WriteLine(jsonConverter.ConvertToJson()); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("**************************************************************************************"); var adapter = new XmlToJsonAdapter(xmlConverter); Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("Converted JSON Data Representation"); Console.WriteLine(adapter.ConvertXmlToJson()); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("**************************************************************************************"); Console.ForegroundColor = ConsoleColor.White; }
public async Task AddMessage(List <EmployeeDto> employeeDtos, MessageStatusEnum messageStatus, MessageTypeEnum messageType, CancellationToken cancellationToken = default) { if (!employeeDtos.Any()) { return; } foreach (var employee in employeeDtos) { var messageExists = await _messageQueueRepository.GetBySystemUniqueId(employee.Id, messageType); if (messageExists != null) { continue; } var message = new MessageQueue { Id = Guid.NewGuid(), SystemUniqueId = employee.Id, SourceRawJson = JsonConverter.ConvertToJson(employee), IsBusyProcessing = false, RetryCount = -1, MessageStatus = messageStatus, MessageType = messageType, CreatedDate = DateTime.UtcNow }; _messageQueueRepository.Add(message); } await _messageQueueRepository.SaveChangesAsync(cancellationToken); }
private void CheckGPUStatus(object callBack, ElapsedEventArgs e) { var gpuList = DeviceManager.GetAllGPUInformation(); var computerName = Environment.MachineName; var currentUser = Environment.UserName; var macAddress = MacAddress.GetFirstMacAddress(); var time = DateTime.Now.ToString("dd/MM/yyyy H:mm:ss"); var PCID = UserConfig == null || UserConfig.PCID.Equals("default") ? $"{computerName}-{currentUser}-{macAddress}" : UserConfig.PCID; UserComputer computer = new UserComputer(PCID, ServiceConfig.UserID, time, gpuList); HttpRequest.SendPostRequest(ServiceConfig.ServerAddress, JsonConverter.ConvertToJson(computer)); }
public void PostBooks(string path) { var bookRequest = new Books { Id = 5, Author = "testt", Title = "asdas" }; //örnek bir veri girerek post edilmesi var Request1 = new RestRequest(); Request1.AddParameter("application/json; charset=utf-8", JsonConverter.ConvertToJson(bookRequest), ParameterType.RequestBody); var _response = Client.Client.Create().Post <Books>(path, Request1); Assert.IsTrue(_response.Contains("Eklendi")); }
private void SetupServiceSection() { //Service status bool isRunning = ServiceManager.CheckIfServiceRunning(SERVICE_NAME); if (isRunning) { this.Dispatcher.Invoke(() => { ServiceStatusIndicator.Fill = new SolidColorBrush(Colors.Green); ServiceStatusTextBlock.Text = "Running"; ServiceStatusTextBlock.Foreground = new SolidColorBrush(Colors.Green); systemTrayIcon.Icon = new Icon(SERVICE_RUNNING_ICON); ToolTipsText += "Running"; }); } else { this.Dispatcher.Invoke(() => { ServiceStatusIndicator.Fill = new SolidColorBrush(Colors.Red); ServiceStatusTextBlock.Text = "Stopped"; ServiceStatusTextBlock.Foreground = new SolidColorBrush(Colors.Red); systemTrayIcon.Icon = new Icon(SERVICE_DOWN_ICON); ToolTipsText += "Service Down"; }); } //Server UserComputer computer = new UserComputer("TestingConnection", 999, "", new List <UserGPU>()); var returnRequest = HttpRequest.SendPostRequest(ServiceConfig.ServerAddress, JsonConverter.ConvertToJson(computer)); if (returnRequest.Equals("OK") || returnRequest.Contains("200")) { this.Dispatcher.Invoke(() => { ServerStatusTextBlock.Foreground = new SolidColorBrush(Colors.Green); ServerStatusTextBlock.Text = "Online"; }); } else { this.Dispatcher.Invoke(() => { ServerStatusTextBlock.Foreground = new SolidColorBrush(Colors.Red); ServerStatusTextBlock.Text = "Offline"; systemTrayIcon.Icon = new Icon(SERVER_DOWN_ICON); ToolTipsText += "\nServer: Offine"; }); } //Internet status if (ConnectionStatus.IsConnected()) { this.Dispatcher.Invoke(() => { InternetStatusTextBlock.Foreground = new SolidColorBrush(Colors.Green); InternetStatusTextBlock.Text = "Connected"; }); } else { this.Dispatcher.Invoke(() => { InternetStatusTextBlock.Foreground = new SolidColorBrush(Colors.Red); InternetStatusTextBlock.Text = "Disconnected"; systemTrayIcon.Icon = new Icon(INTERNET_DOWN_ICON); ToolTipsText += "\nInternet: Disconnected"; }); } }
private HttpContent CreateHttpContent <T>(T content) { var json = JsonConverter.ConvertToJson(content); return(new StringContent(json, Encoding.UTF8, "application/json")); }